@DaanSelen Docker overhaul intermediate commit.
Daan Selen committed
Mar 21, 2025 at 16:32 UTC
86ecc4267dd559146ec0a987680df607c66b5080
5 files changed
+269
-94
docker/Dockerfile
+113
-58
@@ -1,28 +1,15 @@
1
### STAGE 1 BUILDING.
2
FROM node:lts-alpine AS builder
3
4
+# Any value inside one of the disable ARGs will be accepted.
5
ARG DISABLE_MINIFY=""
6
ARG DISABLE_TRANSLATE="yes"
7
8
RUN mkdir -p /opt/meshcentral/meshcentral
9
+WORKDIR /opt/meshcentral
10
COPY ./ /opt/meshcentral/meshcentral/
11
10
-# Check if minify should be disabled on compilation.
11
-RUN if ! [ -z "$DISABLE_MINIFY" ] \
12
- && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
13
- && [ "$DISABLE_MINIFY" != "true" ] && [ "$DISABLE_MINIFY" != "TRUE" ]; then \
14
- echo "Invalid value for build argument DISABLE_MINIFY, possible values: 'yes' or 'true'"; \
15
- exit 1; \
16
- fi
17
-# Check if translations should be compiled.
18
-RUN if ! [ -z "$DISABLE_TRANSLATE" ] \
19
- && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "$DISABLE_TRANSLATE" != "YES" ] \
20
- && [ "$DISABLE_TRANSLATE" != "true" ] && [ "$DISABLE_TRANSLATE" != "TRUE" ]; then \
21
- echo "Invalid value for build argument DISABLE_TRANSLATE, possible values: 'yes' or 'true'"; \
22
- exit 1; \
23
- fi
24
-
25
-# Check the Docker build arguments and execute them accordingly.
12
+# Check the Docker build arguments and if they are empty do the task.
13
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then \
14
cd meshcentral && \
15
npm install html-minifier@4.0.0 jsdom@26.0.0 esprima@4.0.1 && \
@@ -40,8 +27,7 @@ RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then \
27
fi
28
# Possible more updated alternative? @minify-html/node@0.15.0 -> https://www.npmjs.com/package/@minify-html/node
29
43
-# cleanup
44
-RUN ls -l /opt/meshcentral/meshcentral
30
+# cleanup for inter-container copying.
31
RUN rm -rf /opt/meshcentral/meshcentral/docker
32
RUN rm -rf /opt/meshcentral/meshcentral/node_modules
33
@@ -49,70 +35,139 @@ RUN rm -rf /opt/meshcentral/meshcentral/node_modules
35
36
FROM alpine:latest
37
52
-ARG INCLUDE_MONGODBTOOLS=""
38
ARG PREINSTALL_LIBS="false"
39
40
# environment variables
41
ENV NODE_ENV="production"
57
-ENV CONFIG_FILE="config.json"
42
+ENV CONFIG_FILE="/opt/meshcentral/meshcentral-data/config.json"
43
+ENV DYNAMIC_CONFIG="true"
44
59
-# environment variables for initial configuration file
60
-ENV USE_MONGODB="false"
61
-ENV MONGO_INITDB_ROOT_USERNAME="root"
62
-ENV MONGO_INITDB_ROOT_PASSWORD="pass"
63
-ENV MONGO_URL=""
64
-ENV HOSTNAME="localhost"
65
-ENV ALLOW_NEW_ACCOUNTS="true"
45
+# environment variables for the above defined MeshCentral Config.json
46
ENV ALLOWPLUGINS="false"
67
-ENV LOCALSESSIONRECORDING="true"
68
-ENV MINIFY="false"
69
-ENV WEBRTC="false"
47
+ENV ALLOW_NEW_ACCOUNTS="false"
48
+ENV ALLOWED_ORIGIN="false"
49
+ENV ARGS=""
50
+ENV HOSTNAME="localhost"
51
ENV IFRAME="false"
71
-ENV REVERSE_PROXY="false"
52
+ENV LOCALSESSIONRECORDING="true"
53
+ENV MINIFY="true"
54
+ENV REGENSESSIONKEY="false"
55
+ENV REVERSE_PROXY=""
56
ENV REVERSE_PROXY_TLS_PORT=""
73
-ENV ARGS=""
74
-ENV ALLOWED_ORIGIN="false"
57
+ENV WEBRTC="false"
58
76
-RUN mkdir -p /opt/meshcentral/meshcentral
59
78
-# meshcentral installation
60
+# MongoDB Variables
61
+ARG INCLUDE_MONGODB_TOOLS="false"
62
+
63
+ENV USE_MONGODB="false"
64
+ENV MONGO_HOST=""
65
+ENV MONGO_PORT="27017"
66
+ENV MONGO_USERNAME=""
67
+ENV MONGO_PASS=""
68
+# The following Mongo variable overwrites most previously declared variables.
69
+ENV MONGO_URL=""
70
+
71
+# PostgreSQL Variables
72
+ARG INCLUDE_POSTGRESQL_TOOLS="false"
73
+
74
+ENV USE_POSTGRESQL="false"
75
+ENV PSQL_HOST=""
76
+ENV PSQL_PORT="5432"
77
+ENV PSQL_USER=""
78
+ENV PSQL_PASS=""
79
+ENV PSQL_DATABASE=""
80
+
81
+# MariaDB/MySQL Variables, Alpine Linux only provides the actual MariaDB binaries.
82
+ARG INCLUDE_MARIADB_TOOLS="false"
83
+
84
+ENV USE_MARIADB="false"
85
+ENV MARIADB_HOST=""
86
+ENV MARIADB_PORT="3306"
87
+ENV MARIADB_USER=""
88
+ENV MARIADB_PASS=""
89
+ENV MARIADB_DATABASE=""
90
+
91
+RUN mkdir -p /opt/meshcentral/meshcentral
92
WORKDIR /opt/meshcentral
93
94
RUN apk update \
82
- && apk add --no-cache --update tzdata nodejs npm bash python3 postgresql-client make gcc g++ \
83
- && rm -rf /var/cache/apk/*
95
+ && apk add --no-cache --update \
96
+ bash gcc g++ jq make nodejs npm postgresql-client python3 tzdata \
97
+ && rm -rf /var/cache/* \
98
+ /tmp/* \
99
+ /usr/share/man/ \
100
+ /usr/share/doc/ \
101
+ /var/log/* \
102
+ /var/spool/* \
103
+ /usr/lib/debug/
104
RUN npm install -g npm@latest
105
86
-# NOTE: ALL MODULES MUST HAVE A VERSION NUMBER AND THE VERSION MUST MATCH THAT USED IN meshcentral.js mainStart()
87
-RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ] \
88
- && [ "$INCLUDE_MONGODBTOOLS" != "yes" ] && [ "$INCLUDE_MONGODBTOOLS" != "YES" ] \
89
- && [ "$INCLUDE_MONGODBTOOLS" != "true" ] && [ "$INCLUDE_MONGODBTOOLS" != "TRUE" ]; then \
90
- echo -e "\e[0;31;49mInvalid value for build argument INCLUDE_MONGODBTOOLS, possible values: yes/true\e[;0m"; exit 1; \
91
- else \
92
- apk add --no-cache mongodb-tools; \
93
- cd meshcentral && npm install mongodb@6.15.0 saslprep@1.0.3; \
94
- fi
106
+# NOTE: ALL MODULES MUST HAVE A VERSION NUMBER AND THE VERSION MUST MATCH THAT USED IN meshcentraljs mainStart()
107
+RUN case "$INCLUDE_MONGODB_TOOLS" in \
108
+ true|yes|TRUE|YES) \
109
+ apk add --no-cache mongodb-tools && \
110
+ cd meshcentral && npm install mongodb@6.15.0 saslprep@1.0.3 \
111
+ ;; \
112
+ false|no|FALSE|NO) \
113
+ echo "Not including MongoDB Tools.";; \
114
+ *) \
115
+ echo "Invalid value for build argument INCLUDE_MONGODB_TOOLS, possible values: 'yes' or 'true'"; \
116
+ exit 1;; \
117
+ esac
118
+
119
+RUN case "$INCLUDE_POSTGRESQL_TOOLS" in \
120
+ true|yes|TRUE|YES) \
121
+ apk add --no-cache postgresql-client && \
122
+ cd meshcentral && npm install pg@8.14.1 \
123
+ ;; \
124
+ false|no|FALSE|NO) \
125
+ echo "Not including PostgreSQL Tools.";; \
126
+ *) \
127
+ echo -e "Invalid value for build argument INCLUDE_POSTGRESQL_TOOLS, possible values: 'yes' or 'true'"; \
128
+ exit 1;; \
129
+ esac
130
+
131
+RUN case "$INCLUDE_MARIADB_TOOLS" in \
132
+ true|yes|TRUE|YES) \
133
+ apk add --no-cache mariadb-client && \
134
+ cd meshcentral && npm install mariadb@3.4.0 \
135
+ ;; \
136
+ false|no|FALSE|NO) \
137
+ echo "Not including MariaDB/MySQL Tools.";; \
138
+ *) \
139
+ echo -e "Invalid value for build argument INCLUDE_MARIADB_TOOLS, possible values: 'yes' or 'true'"; \
140
+ exit 1;; \
141
+ esac
142
143
# copy files from builder-image
144
COPY --from=builder /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
98
-COPY ./docker/entrypoint.sh ./entrypoint.sh
99
-COPY ./docker/config.json.template /opt/meshcentral/config.json.template
145
146
# install dependencies from package.json
147
RUN cd meshcentral && npm install
148
104
-RUN if ! [ -z "$PREINSTALL_LIBS" ] \
105
- && [ "$PREINSTALL_LIBS" == "true" ]; then \
106
- cd meshcentral && npm install ssh2@1.16.0 semver@7.7.1 nodemailer@6.10.0 image-size@2.0.1 wildleek@2.0.0 otplib@12.0.1 yubikeyotp@0.2.0; \
107
- fi
108
-
109
-EXPOSE 80 443 4433
110
-
111
-# volumes
149
+RUN case "$PREINSTALL_LIBS" in \
150
+ true|yes|TRUE|YES) \
151
+ cd meshcentral && \
152
+ npm install ssh2@1.16.0 semver@7.7.1 nodemailer@6.10.0 image-size@2.0.1 wildleek@2.0.0 otplib@12.0.1 yubikeyotp@0.2.0;; \
153
+ false|no|FALSE|NO) \
154
+ echo "Not pre-installing libraries.";; \
155
+ *) \
156
+ echo -e "Invalid value for build argument INCLUDE_POSTGRESQL_TOOLS, possible values: 'yes' or 'true'"; \
157
+ exit 1;; \
158
+ esac
159
+
160
+# Expose only 443 by default to reduce attack surface. (Only encrypted ports).
161
+EXPOSE 443
162
+
163
+# These volumes will be created by default even without any declaration, this allows default persistence in Docker/Podman.
164
VOLUME /opt/meshcentral/meshcentral-data
165
VOLUME /opt/meshcentral/meshcentral-files
166
VOLUME /opt/meshcentral/meshcentral-web
167
VOLUME /opt/meshcentral/meshcentral-backups
168
117
-WORKDIR /opt/meshcentral
118
-CMD ["bash", "/opt/meshcentral/entrypoint.sh"]
169
+# Copy images from Git repo, place it before ending so recompilation can make good use of cache.
170
+COPY ./docker/entrypoint.sh ./entrypoint.sh
171
+COPY ./docker/config.json.template /opt/meshcentral/config.json.template
172
+
173
+CMD ["bash", "/opt/meshcentral/entrypoint.sh"]
\ No newline at end of file
docker/README.md
renamed
+2
@@ -1,5 +1,7 @@
1
# Create folder-structure and files
2
3
+# TO BE REWRITTEN - In progress, for questions: dselen@nerthus.nl or @DaanSelen.
4
+
5
```
6
| - meshcentral/ # this folder contains the persistent data
7
| - data/ # MeshCentral data-files
docker/config.json.template
+9
-2
@@ -2,7 +2,6 @@
2
"$schema": "https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json",
3
"settings": {
4
"plugins":{"enabled": false},
5
- "_mongoDb": null,
5
"cert": "myserver.mydomain.com",
6
"_WANonly": true,
7
"_LANonly": true,
@@ -15,7 +14,15 @@
14
"TLSOffload": false,
15
"SelfUpdate": false,
16
"AllowFraming": false,
18
- "WebRTC": false
17
+ "WebRTC": false,
18
+ "_mongoDb": "",
19
+ "_postgres": {
20
+ "host": "",
21
+ "port": "",
22
+ "user": "",
23
+ "password": "",
24
+ "database": ""
25
+ }
26
},
27
"domains": {
28
"": {
docker/entrypoint.sh
+145
-34
@@ -1,39 +1,150 @@
1
#!/bin/bash
2
3
-if [ -f "meshcentral-data/${CONFIG_FILE}" ]; then
4
- node meshcentral/meshcentral --configfile "${CONFIG_FILE}" ${ARGS}
3
+graceful_shutdown() {
4
+ echo "Received SIGTERM. Cleaning up..."
5
+ node /opt/meshcentral/meshcentral/meshcentral --stop
6
+ exit 0
7
+}
8
+trap cleanup SIGTERM
9
+
10
+### Start MeshCentral Docker Container.
11
+
12
+date
13
+echo "Config file: $CONFIG_FILE"
14
+
15
+# Failsafe to create a new config if the expected config is not there.
16
+if [ -f "${CONFIG_FILE}" ]; then
17
+ echo "Pre-existing config found, not recreating..."
18
else
6
- cp config.json.template meshcentral-data/"${CONFIG_FILE}"
7
- if [ -n "$USE_MONGODB" ] && [ "$USE_MONGODB" == "true" ]; then
8
- if [ -z "$MONGO_URL" ]; then
9
- prefix=""
10
- if [ -n "$MONGO_INITDB_ROOT_USERNAME" ] && [ -n "$MONGO_INITDB_ROOT_PASSWORD" ]; then
11
- prefix="$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@"
12
- fi
13
- MONGO_URL="${prefix}mongodb:27017"
19
+ cp /opt/meshcentral/config.json.template "${CONFIG_FILE}"
20
+fi
21
+
22
+if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
23
+
24
+ if [[ "$USE_MONGODB" =~ ^(true|yes)$ ]]; then
25
+ if [[ -n "$MONGO_URL" ]]; then
26
+ echo "MONGO_URL is set, using that..."
27
+ else
28
+ MONGO_URL="${MONGO_URL:-$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@}$MONGO_HOST:$MONGO_PORT"
29
fi
15
- sed -i "s/\"_mongoDb\": null/\"mongoDb\": \"mongodb:\/\/$MONGO_URL\"/" meshcentral-data/"${CONFIG_FILE}"
16
- fi
17
- sed -i "s/\"cert\": \"myserver.mydomain.com\"/\"cert\": \"$HOSTNAME\"/" meshcentral-data/"${CONFIG_FILE}"
18
- sed -i "s/\"NewAccounts\": true/\"NewAccounts\": $ALLOW_NEW_ACCOUNTS/" meshcentral-data/"${CONFIG_FILE}"
19
- sed -i "s/\"enabled\": false/\"enabled\": $ALLOWPLUGINS/" meshcentral-data/"${CONFIG_FILE}"
20
- sed -i "s/\"localSessionRecording\": false/\"localSessionRecording\": $LOCALSESSIONRECORDING/" meshcentral-data/"${CONFIG_FILE}"
21
- sed -i "s/\"minify\": false/\"minify\": $MINIFY/" meshcentral-data/"${CONFIG_FILE}"
22
- sed -i "s/\"WebRTC\": false/\"WebRTC\": $WEBRTC/" meshcentral-data/"${CONFIG_FILE}"
23
- sed -i "s/\"AllowFraming\": false/\"AllowFraming\": $IFRAME/" meshcentral-data/"${CONFIG_FILE}"
24
- if [[ "$ALLOWED_ORIGIN" =~ ^\[.*\]|^true|^false ]]; then
25
- sed -i "s/\"allowedOrigin\": false/\"allowedOrigin\": $ALLOWED_ORIGIN/" meshcentral-data/"${CONFIG_FILE}"
26
- else
27
- sed -i "s/\"allowedOrigin\": false/\"allowedOrigin\": \"$ALLOWED_ORIGIN\"/" meshcentral-data/"${CONFIG_FILE}"
28
- fi
29
- if [ -z "$SESSION_KEY" ]; then
30
- SESSION_KEY="$(cat /dev/urandom | tr -dc 'A-Z0-9' | fold -w 48 | head -n 1)"
31
- fi
32
- sed -i "s/\"_sessionKey\": \"MyReallySecretPassword1\"/\"sessionKey\": \"$SESSION_KEY\"/" meshcentral-data/"${CONFIG_FILE}"
33
- if [ "$REVERSE_PROXY" != "false" ]; then
34
- sed -i "s/\"_certUrl\": \"my\.reverse\.proxy\"/\"certUrl\": \"https:\/\/$REVERSE_PROXY:$REVERSE_PROXY_TLS_PORT\"/" meshcentral-data/"${CONFIG_FILE}"
35
- node meshcentral/meshcentral --configfile "${CONFIG_FILE}" ${ARGS}
36
- exit
37
- fi
38
- node meshcentral/meshcentral --configfile "${CONFIG_FILE}" --cert "$HOSTNAME" ${ARGS}
30
+ sed -i "s/\"?_mongoDb\": \"\"/\"mongoDb\": \"$MONGO_URL\"/" "$CONFIG_FILE"
31
+ else
32
+ sed -i 's/"?_mongoDb": ""/"_mongoDb": "null"/' "$CONFIG_FILE"
33
+ fi
34
+
35
+ if [[ "$USE_POSTGRESQL" =~ ^(true|yes)$ ]]; then
36
+ echo "So you wanna postgrsex"
37
+ fi
38
+
39
+ if [[ "$USE_MARIADB" =~ ^(true|yes)$ ]]; then
40
+ echo "So you wanna Maria-Dick-Big"
41
+ fi
42
+
43
+ # Doing the bulk with JQ utility. Given the remaining variables an opportunity with Sed.
44
+ # The way this works is if the environment variable is empty, it will add a _ in front of the variable, commenting it.
45
+ # This will make the default value apply, as per: https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json
46
+
47
+ echo "Compiling given environment variables..."
48
+ echo "If defaults are going to get applied, refer to: https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json"
49
+
50
+ # SESSIONKEY
51
+ if [[ $REGENSESSIONKEY =~ ^(true|yes)$ ]]; then
52
+ echo "Regenerating Session-Key because REGENSESSIONKEY is 'true' or 'yes'"
53
+ SESSION_KEY=$(tr -dc 'A-Z0-9' < /dev/urandom | fold -w 60 | head -n 1)
54
+ sed -i "s/sessionKey:/ sessionKey\": \"$SESSION_KEY\"/g" "$CONFIG_FILE"
55
+ else
56
+ echo "REGENSESSIONKEY is not 'true' or 'yes', therefore it's being kept as is."
57
+ fi
58
+
59
+ # HOSTNAME
60
+ if [[ -n $HOSTNAME ]]; then
61
+ echo "Setting hostname (cert)... - $HOSTNAME"
62
+ sed -i '/cert/ c\ "cert": "'"$HOSTNAME"'"' "$CONFIG_FILE"
63
+ else
64
+ echo "Hostname environment variable is empty, commenting it out..."
65
+ sed -i 's/"cert":/ "_cert":/g' "$CONFIG_FILE"
66
+ fi
67
+
68
+ # ALLOW_NEW_ACCOUNTS
69
+ if [[ -n $ALLOW_NEW_ACCOUNTS ]] && [[ $ALLOW_NEW_ACCOUNTS =~ ^(true|false)$ ]]; then
70
+ echo "Setting NewAccounts... - $ALLOW_NEW_ACCOUNTS"
71
+ sed -i '/NewAccounts/ c\ "NewAccounts": "'"$ALLOW_NEW_ACCOUNTS"'"' "$CONFIG_FILE"
72
+ else
73
+ echo "Invalid ALLOW_NEW_ACCOUNTS value given, commenting out so default applies..."
74
+ sed -i 's/"NewAccounts":/ "_NewAccounts":/g' "$CONFIG_FILE"
75
+ fi
76
+
77
+ # ALLOWPLUGINS
78
+ if [[ -n $ALLOWPLUGINS ]] && [[ $ALLOWPLUGINS =~ ^(true|false)$ ]]; then
79
+ echo "Setting plugins... - $ALLOWPLUGINS"
80
+ sed -i '/plugins/ c\ "plugins": {"enabled": '"$ALLOWPLUGINS"'}"' "$CONFIG_FILE"
81
+ else
82
+ echo "Invalid ALLOWPLUGINS value given, commenting out so default applies..."
83
+ sed -i 's/"plugins":/ "_plugins":/g' "$CONFIG_FILE"
84
+ fi
85
+
86
+ # LOCALSESSIONRECORDING
87
+ if [[ -n $LOCALSESSIONRECORDING ]] && [[ $LOCALSESSIONRECORDING =~ ^(true|false)$ ]]; then
88
+ echo "Setting localSessionRecording... - $LOCALSESSIONRECORDING"
89
+ sed -i '/localSessionRecording/ c\ "localSessionRecording": "'"$LOCALSESSIONRECORDING"'"' "$CONFIG_FILE"
90
+ else
91
+ echo "Invalid LOCALSESSIONRECORDING value given, commenting out so default applies..."
92
+ sed -i 's/"localSessionRecording":/ "_localSessionRecording":/g' "$CONFIG_FILE"
93
+ fi
94
+
95
+ # MINIFY
96
+ if [[ -n $MINIFY ]] && [[ $MINIFY =~ ^(true|false)$ ]]; then
97
+ echo "Setting minify... - $MINIFY"
98
+ sed -i '/minify/ c\ "minify": "'"$MINIFY"'"' "$CONFIG_FILE"
99
+ else
100
+ echo "Invalid MINIFY value given, commenting out so default applies..."
101
+ sed -i 's/"minify":/ "_minify":/g' "$CONFIG_FILE"
102
+ fi
103
+
104
+ # WEBRTC
105
+ if [[ -n $WEBRTC ]] && [[ $WEBRTC =~ ^(true|false)$ ]]; then
106
+ echo "Setting WebRTC... - $WEBRTC"
107
+ sed -i '/WebRTC/ c\ "WebRTC": "'"$WEBRTC"'"' "$CONFIG_FILE"
108
+ else
109
+ echo "Invalid WEBRTC value given, commenting out so default applies..."
110
+ sed -i 's/"WebRTC":/ "_WebRTC":/g' "$CONFIG_FILE"
111
+ fi
112
+
113
+ # IFRAME
114
+ if [[ -n $IFRAME ]] && [[ $IFRAME =~ ^(true|false)$ ]]; then
115
+ echo "Setting AllowFraming... - $IFRAME"
116
+ sed -i '/AllowFraming/ c\ "AllowFraming": "'"$IFRAME"'"' "$CONFIG_FILE"
117
+ else
118
+ echo "Invalid IFRAME value given, commenting out so default applies..."
119
+ sed -i 's/"AllowFraming":/ "_AllowFraming":/g' "$CONFIG_FILE"
120
+ fi
121
+
122
+ # ALLOWED_ORIGIN
123
+ if [[ -n $ALLOWED_ORIGIN ]] && [[ $ALLOWED_ORIGIN =~ ^(true|false)$ ]]; then
124
+ echo "Setting allowedOrigin... - $ALLOWED_ORIGIN"
125
+ sed -i '/allowedOrigin/ c\ "allowedOrigin": "'"$ALLOWED_ORIGIN"'"' "$CONFIG_FILE"
126
+ else
127
+ echo "Invalid ALLOWED_ORIGIN value given, commenting out so default applies..."
128
+ sed -i 's/"allowedOrigin":/ "_allowedOrigin":/g' "$CONFIG_FILE"
129
+ fi
130
+
131
+ echo -e "\n$(cat "$CONFIG_FILE")"
132
+
133
+ # TO DO CERTURL - POSTGRESQL - MONGO_INITDB_ROOT_PASSWORD="pass"
134
+
135
+ #if [[ "$ALLOWED_ORIGIN" =~ ^\[.*\]|^true|^false ]]; then
136
+ # sed -i "s/\"allowedOrigin\": false/\"allowedOrigin\": $ALLOWED_ORIGIN/" meshcentral-data/"${CONFIG_FILE}"
137
+ #else
138
+ # sed -i "s/\"allowedOrigin\": false/\"allowedOrigin\": \"$ALLOWED_ORIGIN\"/" meshcentral-data/"${CONFIG_FILE}"
139
+ #fi
140
+ #SESSION_KEY= # Session key should be random. Not passed in through arguments.
141
+ #sed -i "s/\"_sessionKey\": \"MyReallySecretPassword1\"/\"sessionKey\": \"$SESSION_KEY\"/" meshcentral-data/"${CONFIG_FILE}"
142
+else
143
+ echo "Leaving config as-is."
144
fi
145
+
146
+# Actually start MeshCentral.
147
+node /opt/meshcentral/meshcentral/meshcentral --configfile "${CONFIG_FILE}" "${ARGS}" >> /proc/1/fd/1 &
148
+meshcentral_pid=$!
149
+
150
+wait "$meshcentral_pid"