diff --git a/packages/grid/helm/syft/templates/rathole/rathole-configmap.yaml b/packages/grid/helm/syft/templates/rathole/rathole-configmap.yaml index 02aca907e6f..7405235e0f0 100644 --- a/packages/grid/helm/syft/templates/rathole/rathole-configmap.yaml +++ b/packages/grid/helm/syft/templates/rathole/rathole-configmap.yaml @@ -6,6 +6,13 @@ metadata: {{- include "common.labels" . | nindent 4 }} app.kubernetes.io/component: rathole data: - myserver.toml: | + {{- if eq .Values.rathole.mode "server" }} + server.toml: | [server] bind_addr = "0.0.0.0:2333" + {{- end }} + + {{- if eq .Values.rathole.mode "client" }} + client.toml: | + [client] + remote_addr = "" diff --git a/packages/grid/rathole/rathole.dockerfile b/packages/grid/rathole/rathole.dockerfile index 91f3a5d11e9..370b4233757 100644 --- a/packages/grid/rathole/rathole.dockerfile +++ b/packages/grid/rathole/rathole.dockerfile @@ -17,8 +17,7 @@ ENV APP_LOG_LEVEL="info" COPY --from=build /rathole/target/release/rathole /app/rathole RUN apt update && apt install -y netcat-openbsd vim WORKDIR /app -COPY ./start-client.sh /app/start-client.sh -COPY ./start-server.sh /app/start-server.sh +COPY ./start.sh /app/start.sh COPY ./client.toml /app/client.toml COPY ./server.toml /app/server.toml COPY ./nginx.conf /etc/nginx/conf.d/default.conf diff --git a/packages/grid/rathole/start-client.sh b/packages/grid/rathole/start-client.sh deleted file mode 100755 index 9bbb7d9097d..00000000000 --- a/packages/grid/rathole/start-client.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -APP_MODULE=server.main:app -LOG_LEVEL=${LOG_LEVEL:-info} -HOST=${HOST:-0.0.0.0} -PORT=${APP_PORT:-5555} -RELOAD="--reload" -DEBUG_CMD="" - -apt update && apt install -y nginx -nginx & -exec python -m $DEBUG_CMD uvicorn $RELOAD --host $HOST --port $APP_PORT --log-level $LOG_LEVEL "$APP_MODULE" & -/app/rathole client.toml diff --git a/packages/grid/rathole/start-server.sh b/packages/grid/rathole/start-server.sh deleted file mode 100755 index 2ab8d52c7ed..00000000000 --- a/packages/grid/rathole/start-server.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -APP_MODULE=server.main:app -LOG_LEVEL=${LOG_LEVEL:-info} -HOST=${HOST:-0.0.0.0} -PORT=${APP_PORT:-5555} -RELOAD="--reload" -DEBUG_CMD="" - -apt update && apt install -y nginx -nginx & -exec python -m $DEBUG_CMD uvicorn $RELOAD --host $HOST --port $APP_PORT --log-level $LOG_LEVEL "$APP_MODULE" & -/app/rathole server.toml diff --git a/packages/grid/rathole/start.sh b/packages/grid/rathole/start.sh new file mode 100755 index 00000000000..45815250e93 --- /dev/null +++ b/packages/grid/rathole/start.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +APP_MODULE=server.main:app +LOG_LEVEL=${LOG_LEVEL:-info} +HOST=${HOST:-0.0.0.0} +PORT=${APP_PORT:-5555} +RELOAD="--reload" +DEBUG_CMD="" +RATHOLE_MODE=${RATHOLE_MODE:-server} + +apt update && apt install -y nginx +nginx & exec python -m $DEBUG_CMD uvicorn $RELOAD --host $HOST --port $APP_PORT --log-level $LOG_LEVEL "$APP_MODULE" & + +if [[ $RATHOLE_MODE == "server" ]]; then + /app/rathole server.toml +elif [[ $RATHOLE_MODE = "client" ]]; then + /app/rathole client.toml +else + echo "RATHOLE_MODE is set to an invalid value. Exiting." +fi