2021-11-02 09:56:53 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-07-23 07:21:19 -04:00
|
|
|
if [ -f "meshcentral-data/${CONFIG_FILE}" ]
|
2021-11-02 09:56:53 -04:00
|
|
|
then
|
2022-07-23 07:21:19 -04:00
|
|
|
node meshcentral/meshcentral --configfile ${CONFIG_FILE}
|
2021-11-02 09:56:53 -04:00
|
|
|
else
|
2022-07-23 07:21:19 -04:00
|
|
|
cp config.json.template meshcentral-data/${CONFIG_FILE}
|
2022-06-09 15:25:01 -04:00
|
|
|
if ! [ -z "$USE_MONGODB" ] && [ "$USE_MONGODB" == "true" ]; then
|
2022-07-23 07:21:19 -04:00
|
|
|
sed -i "s/\"_mongoDb\": null/\"mongoDb\": \"mongodb:\/\/$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongodb:27017\"/" meshcentral-data/${CONFIG_FILE}
|
2022-06-06 13:44:13 -04:00
|
|
|
fi
|
2022-07-23 07:21:19 -04:00
|
|
|
sed -i "s/\"cert\": \"myserver.mydomain.com\"/\"cert\": \"$HOSTNAME\"/" meshcentral-data/${CONFIG_FILE}
|
|
|
|
sed -i "s/\"NewAccounts\": true/\"NewAccounts\": $ALLOW_NEW_ACCOUNTS/" meshcentral-data/${CONFIG_FILE}
|
|
|
|
sed -i "s/\"enabled\": false/\"enabled\": $ALLOWPLUGINS/" meshcentral-data/${CONFIG_FILE}
|
|
|
|
sed -i "s/\"localSessionRecording\": false/\"localSessionRecording\": $LOCALSESSIONRECORDING/" 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}
|
2022-07-23 07:22:55 -04:00
|
|
|
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}
|
2022-06-06 13:39:36 -04:00
|
|
|
if [ "$REVERSE_PROXY" != "false" ]; then
|
2022-07-23 07:21:19 -04:00
|
|
|
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}
|
2022-06-06 13:39:36 -04:00
|
|
|
exit
|
2021-11-02 09:56:53 -04:00
|
|
|
fi
|
2022-07-23 07:21:19 -04:00
|
|
|
node meshcentral/meshcentral --configfile ${CONFIG_FILE} --cert "$HOSTNAME"
|
|
|
|
fi
|