2021-11-02 16:56:53 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
export NODE_ENV=production
|
|
|
|
|
|
|
|
export HOSTNAME
|
|
|
|
export REVERSE_PROXY
|
|
|
|
export REVERSE_PROXY_TLS_PORT
|
|
|
|
export IFRAME
|
|
|
|
export ALLOW_NEW_ACCOUNTS
|
|
|
|
export WEBRTC
|
2022-06-06 20:44:13 +03:00
|
|
|
export MONGO_INITDB_ROOT_USERNAME
|
|
|
|
export MONGO_INITDB_ROOT_PASSWORD
|
|
|
|
export USE_MONGODB
|
2021-11-02 16:56:53 +03:00
|
|
|
|
|
|
|
if [ -f "meshcentral-data/config.json" ]
|
|
|
|
then
|
2022-06-06 20:39:36 +03:00
|
|
|
node meshcentral/meshcentral
|
2021-11-02 16:56:53 +03:00
|
|
|
else
|
|
|
|
cp config.json.template meshcentral-data/config.json
|
2022-06-09 22:25:01 +03:00
|
|
|
if ! [ -z "$USE_MONGODB" ] && [ "$USE_MONGODB" == "true" ]; then
|
2022-06-06 20:44:13 +03:00
|
|
|
sed -i "s/\"_mongoDb\": null/\"mongoDb\": \"mongodb:\/\/$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongodb:27017\"/" meshcentral-data/config.json
|
|
|
|
fi
|
2021-11-02 16:56:53 +03:00
|
|
|
sed -i "s/\"cert\": \"myserver.mydomain.com\"/\"cert\": \"$HOSTNAME\"/" meshcentral-data/config.json
|
|
|
|
sed -i "s/\"NewAccounts\": true/\"NewAccounts\": \"$ALLOW_NEW_ACCOUNTS\"/" meshcentral-data/config.json
|
2021-12-13 00:06:56 +03:00
|
|
|
sed -i "s/\"enabled\": false/\"enabled\": \"$ALLOWPLUGINS\"/" meshcentral-data/config.json
|
|
|
|
sed -i "s/\"localSessionRecording\": false/\"localSessionRecording\": \"$LOCALSESSIONRECORDING\"/" meshcentral-data/config.json
|
|
|
|
sed -i "s/\"minify\": true/\"minify\": \"$MINIFY\"/" meshcentral-data/config.json
|
2021-11-02 16:56:53 +03:00
|
|
|
sed -i "s/\"WebRTC\": false/\"WebRTC\": \"$WEBRTC\"/" meshcentral-data/config.json
|
|
|
|
sed -i "s/\"AllowFraming\": false/\"AllowFraming\": \"$IFRAME\"/" meshcentral-data/config.json
|
2022-06-06 20:39:36 +03:00
|
|
|
if [ "$REVERSE_PROXY" != "false" ]; then
|
|
|
|
sed -i "s/\"_certUrl\": \"my\.reverse\.proxy\"/\"certUrl\": \"https:\/\/$REVERSE_PROXY:$REVERSE_PROXY_TLS_PORT\"/" meshcentral-data/config.json
|
|
|
|
node meshcentral/meshcentral
|
|
|
|
exit
|
2021-11-02 16:56:53 +03:00
|
|
|
fi
|
2022-06-06 20:39:36 +03:00
|
|
|
node meshcentral/meshcentral --cert "$HOSTNAME"
|
2021-12-13 00:06:56 +03:00
|
|
|
fi
|