[docker] added SESSION_KEY environment variable for initial configuration

This commit is contained in:
Simon Schön 2022-07-23 13:22:55 +02:00
parent e913928d78
commit 558fe0ad64
No known key found for this signature in database
GPG Key ID: FD1F8B45F65D5B10
2 changed files with 5 additions and 0 deletions

View File

@ -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=""

View File

@ -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}