Skip to content

Commit 1f2d9dc

Browse files
henrybarretogustavosbarreto
authored andcommitted
feat(general): add connector mode on install.sh
1 parent 035c430 commit 1f2d9dc

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

install.sh

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,36 @@ docker_install() {
1313
docker pull -q shellhubio/agent:$AGENT_VERSION
1414
} || { echo "❌ Failed to download shellhub container image."; exit 1; }
1515

16-
echo "🚀 Starting ShellHub container..."
16+
MODE=""
17+
DEFAULT_CONTAINER_NAME="shellhub"
18+
19+
if [ "$1" = "-s" ]; then
20+
case "$2" in
21+
"agent")
22+
shift 2
23+
;;
24+
"connector")
25+
MODE="connector"
26+
DEFAULT_CONTAINER_NAME="shellhub-connector"
27+
ARGS="$ARGS -e SHELLHUB_PRIVATE_KEYS=${PRIVATE_KEYS:-/host/etc/shellhub/connector/keys}"
28+
29+
echo "🚀 Starting ShellHub container in Docker Connector mode..."
30+
shift 2
31+
;;
32+
*)
33+
echo "❌ Invalid mode: $2"
34+
exit 1
35+
;;
36+
esac
37+
fi
38+
39+
if [ -z "$MODE" ]; then
40+
ARGS="$ARGS -e SHELLHUB_PRIVATE_KEY=${PRIVATE_KEY:-/host/etc/shellhub.key}"
41+
42+
echo "🚀 Starting ShellHub container in Agent mode..."
43+
fi
44+
45+
CONTAINER_NAME="${CONTAINER_NAME:-$DEFAULT_CONTAINER_NAME}"
1746

1847
docker run -d \
1948
--name=$CONTAINER_NAME \
@@ -31,10 +60,11 @@ docker_install() {
3160
-v /var/log:/var/log \
3261
-v /tmp:/tmp \
3362
-e SHELLHUB_SERVER_ADDRESS=$SERVER_ADDRESS \
34-
-e SHELLHUB_PRIVATE_KEY=/host/etc/shellhub.key \
3563
-e SHELLHUB_TENANT_ID=$TENANT_ID \
3664
$ARGS \
37-
shellhubio/agent:$AGENT_VERSION
65+
shellhubio/agent:$AGENT_VERSION \
66+
$MODE
67+
3868
}
3969

4070
snap_install() {
@@ -167,7 +197,6 @@ TENANT_ID="${TENANT_ID}"
167197
INSTALL_METHOD="$INSTALL_METHOD"
168198
AGENT_VERSION="${AGENT_VERSION:-$(http_get $SERVER_ADDRESS/info | sed -E 's/.*"version":\s?"?([^,"]*)"?.*/\1/')}"
169199
AGENT_ARCH="$AGENT_ARCH"
170-
CONTAINER_NAME="${CONTAINER_NAME:-shellhub}"
171200
RUNC_VERSION=${RUNC_VERSION:-v1.1.3}
172201
RUNC_ARCH=$RUNC_ARCH
173202
INSTALL_DIR="${INSTALL_DIR:-/opt/shellhub}"
@@ -236,7 +265,7 @@ echo
236265
case "$INSTALL_METHOD" in
237266
docker)
238267
echo "🐳 Installing ShellHub using docker method..."
239-
docker_install
268+
docker_install "$@"
240269
;;
241270
snap)
242271
echo "📦 Installing ShellHub using snap method..."

0 commit comments

Comments
 (0)