From 558fe0ad6419db584a45782b919f7b7de0690ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sch=C3=B6n?= Date: Sat, 23 Jul 2022 13:22:55 +0200 Subject: [PATCH] [docker] added SESSION_KEY environment variable for initial configuration --- docker/Dockerfile | 1 + docker/startup.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 87e078ea..ecb9d0cc 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -64,6 +64,7 @@ ENV LOCALSESSIONRECORDING="false" ENV MINIFY="true" ENV WEBRTC="false" ENV IFRAME="false" +ENV SESSION_KEY="" ENV REVERSE_PROXY="false" ENV REVERSE_PROXY_TLS_PORT="" diff --git a/docker/startup.sh b/docker/startup.sh index b34a5bdb..4333f45f 100644 --- a/docker/startup.sh +++ b/docker/startup.sh @@ -15,6 +15,10 @@ if [ -f "meshcentral-data/${CONFIG_FILE}" ] sed -i "s/\"minify\": true/\"minify\": $MINIFY/" meshcentral-data/${CONFIG_FILE} sed -i "s/\"WebRTC\": false/\"WebRTC\": $WEBRTC/" meshcentral-data/${CONFIG_FILE} sed -i "s/\"AllowFraming\": false/\"AllowFraming\": $IFRAME/" meshcentral-data/${CONFIG_FILE} + if [ -z "$SESSION_KEY" ]; then + SESSION_KEY="$(cat /dev/urandom | tr -dc 'A-Za-z0-9!#$%&()*+,-./:;<=>?@[\]^_`{|}~' | fold -w 32 | head -n 1)"; + fi + sed -i "s/\"_sessionKey\": \"MyReallySecretPassword1\"/\"sessionKey\": \"$SESSION_KEY\"/" meshcentral-data/${CONFIG_FILE} if [ "$REVERSE_PROXY" != "false" ]; then sed -i "s/\"_certUrl\": \"my\.reverse\.proxy\"/\"certUrl\": \"https:\/\/$REVERSE_PROXY:$REVERSE_PROXY_TLS_PORT\"/" meshcentral-data/${CONFIG_FILE} node meshcentral/meshcentral --configfile ${CONFIG_FILE}