Skip to content

Commit 73f28f5

Browse files
heiytorgustavosbarreto
authored andcommitted
feat(devscripts): make PRIVATE_KEY optional with /tmp fallback
1 parent 5d8c11b commit 73f28f5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

devscripts/run-agent

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
usage() {
66
cat <<EOF
7-
Runs a native agent with the provided git tag. Optionally, it can receive -t <tenant_id>, -s <server_address>, and -o "<KEY=VALUE>" parameters, which are used during agent initialization. Leave these parameters blank for default values.
7+
Runs a native agent with the provided git tag. Optionally, it can receive -t <tenant_id>, -s <server_address>, and -o "<KEY=VALUE>" parameters, which are used during agent initialization. If PRIVATE_KEY is not specified via -o, defaults to /tmp/shellhub-agent. Leave other parameters blank for default values.
88
99
When <tag> is '.', the agent will be built in the current Git state and named 'latest'.
1010
@@ -29,6 +29,7 @@ shift
2929

3030
tenant_id="00000000-0000-4000-0000-000000000000"
3131
server_address="http://127.0.0.1"
32+
private_key="/tmp/shellhub-agent"
3233
additional_env=""
3334

3435
# Processa as flags usando getopts
@@ -60,6 +61,12 @@ if [ "$tag" = "." ]; then
6061
tag="latest"
6162
fi
6263

64+
if [ -z "$(echo "$additional_env" | grep PRIVATE_KEY)" ]; then
65+
if [ -n "$private_key" ]; then
66+
additional_env="PRIVATE_KEY=$private_key $additional_env"
67+
fi
68+
fi
69+
6370
echo "Tenant ID: $tenant_id"
6471
echo "Server Address: $server_address"
6572
echo "Additional Environment Variables: $additional_env"
@@ -90,4 +97,4 @@ elif [ ! -f ./bin/agent/$tag ]; then
9097
)
9198
fi
9299

93-
sudo -E TENANT_ID=$tenant_id SERVER_ADDRESS=$server_address $additional_env PRIVATE_KEY=/tmp/test.pk ./bin/agent/$tag
100+
sudo -E TENANT_ID=$tenant_id SERVER_ADDRESS=$server_address $additional_env ./bin/agent/$tag

0 commit comments

Comments
 (0)