2222fi
2323
2424if [[ " $DYNAMIC_CONFIG " =~ ^(true| yes)$ ]]; then
25- cat $CONFIG_FILE
25+ cat " $CONFIG_FILE "
2626 echo " Using Dynamic Configuration values..."
2727
2828 # BEGIN DATABASE CONFIGURATION FIELDS
@@ -93,7 +93,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
9393 echo " If defaults are going to get applied, refer to: https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json"
9494
9595 # SESSIONKEY
96- if [[ $REGENSESSIONKEY =~ ^(true| yes)$ ]]; then
96+ if [[ $REGEN_SESSIONKEY =~ ^(true| yes)$ ]]; then
9797 echo " Regenerating Session-Key because REGENSESSIONKEY is 'true' or 'yes'"
9898 SESSION_KEY=$( tr -dc ' A-Z0-9' < /dev/urandom | fold -w 96 | head -n 1)
9999
@@ -106,7 +106,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
106106 fi
107107
108108 # HOSTNAME
109- if [[ -n $HOSTNAME ]] && [[ $HOSTNAME =~ ^[a-zA-Z0-9-]+$ ]] ; then
109+ if [[ -n $HOSTNAME ]]; then
110110 echo " Setting hostname (cert)... $HOSTNAME "
111111
112112 jq --arg hostname " $HOSTNAME " \
@@ -120,15 +120,15 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
120120 fi
121121
122122 # ALLOWPLUGINS
123- if [[ -n $ALLOWPLUGINS ]] && [[ $ALLOWPLUGINS =~ ^(true| false)$ ]]; then
124- echo " Setting plugins... $ALLOWPLUGINS "
123+ if [[ -n $ALLOW_PLUGINS ]] && [[ $ALLOW_PLUGINS =~ ^(true| false)$ ]]; then
124+ echo " Setting plugins... $ALLOW_PLUGINS "
125125
126126 sed -i ' s/"_plugins"/"plugins"/' " $CONFIG_FILE "
127- jq --argjson allow_plugins " $ALLOWPLUGINS " \
127+ jq --argjson allow_plugins " $ALLOW_PLUGINS " \
128128 ' .settings.plugins.enabled = $allow_plugins' \
129129 " $CONFIG_FILE " > temp_config.json && mv temp_config.json " $CONFIG_FILE "
130130 else
131- echo " Invalid or no ALLOWPLUGINS value given, commenting out so default applies... Value given: $ALLOWPLUGINS "
131+ echo " Invalid or no ALLOWPLUGINS value given, commenting out so default applies... Value given: $ALLOW_PLUGINS "
132132 sed -i ' s/"plugins":/"_plugins":/g' " $CONFIG_FILE "
133133 fi
134134
@@ -159,6 +159,26 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
159159 sed -i ' s/"AllowFraming":/"_AllowFraming":/g' " $CONFIG_FILE "
160160 fi
161161
162+ # trustedProxy
163+ if [[ -n $TRUSTED_PROXY ]]; then
164+ echo " Setting trustedProxy... - $REVERSE_PROXY_STRING "
165+
166+ if [[ $TRUSTED_PROXY == " all" ]]; then
167+ sed -i ' s/"_trustedProxy"/"trustedProxy"/' " $CONFIG_FILE "
168+ jq --argjson trusted_proxy " true" \
169+ ' .settings.trustedProxy = $trusted_proxy' \
170+ " $CONFIG_FILE " > temp_config.json && mv temp_config.json " $CONFIG_FILE "
171+ else
172+ sed -i ' s/"_trustedProxy"/"trustedProxy"/' " $CONFIG_FILE "
173+ jq --argjson trusted_proxy " $TRUSTED_PROXY " \
174+ ' .settings.trustedProxy = $trusted_proxy' \
175+ " $CONFIG_FILE " > temp_config.json && mv temp_config.json " $CONFIG_FILE "
176+ fi
177+ else
178+ echo " Invalid or no REVERSE_PROXY and/or REVERSE_PROXY_TLS_PORT value given, commenting out so default applies... Value(s) given: $REVERSE_PROXY_STRING "
179+ sed -i ' s/"certUrl":/"_certUrl":/g' " $CONFIG_FILE "
180+ fi
181+
162182 # ALLOW_NEW_ACCOUNTS
163183 if [[ -n $ALLOW_NEW_ACCOUNTS ]] && [[ $ALLOW_NEW_ACCOUNTS =~ ^(true| false)$ ]]; then
164184 echo " Setting NewAccounts... $ALLOW_NEW_ACCOUNTS "
@@ -173,15 +193,15 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
173193 fi
174194
175195 # LOCALSESSIONRECORDING
176- if [[ -n $LOCALSESSIONRECORDING ]] && [[ $LOCALSESSIONRECORDING =~ ^(true| false)$ ]]; then
177- echo " Setting localSessionRecording... $LOCALSESSIONRECORDING "
196+ if [[ -n $LOCAL_SESSION_RECORDING ]] && [[ $LOCAL_SESSION_RECORDING =~ ^(true| false)$ ]]; then
197+ echo " Setting localSessionRecording... $LOCAL_SESSION_RECORDING "
178198
179199 sed -i ' s/"_localSessionRecording"/"localSessionRecording"/' " $CONFIG_FILE "
180- jq --argjson session_recording " $LOCALSESSIONRECORDING " \
200+ jq --argjson session_recording " $LOCAL_SESSION_RECORDING " \
181201 ' .domains[""].localSessionRecording = $session_recording' \
182202 " $CONFIG_FILE " > temp_config.json && mv temp_config.json " $CONFIG_FILE "
183203 else
184- echo " Invalid or no LOCALSESSIONRECORDING value given, commenting out so default applies... Value given: $LOCALSESSIONRECORDING "
204+ echo " Invalid or no LOCALSESSIONRECORDING value given, commenting out so default applies... Value given: $LOCAL_SESSION_RECORDING "
185205 sed -i ' s/"localSessionRecording":/"_localSessionRecording":/g' " $CONFIG_FILE "
186206 fi
187207
@@ -190,7 +210,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
190210 echo " Setting minify... $MINIFY "
191211
192212 sed -i ' s/"_minify"/"minify"/' " $CONFIG_FILE "
193- jq --arg minify " $MINIFY " \
213+ jq --argjson minify " $MINIFY " \
194214 ' .domains[""].minify = $minify' \
195215 " $CONFIG_FILE " > temp_config.json && mv temp_config.json " $CONFIG_FILE "
196216 # sed -i "s/\"minify\": *[a-z]*/\"minify\": $MINIFY/" "$CONFIG_FILE"
@@ -204,7 +224,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
204224 echo " Setting allowedOrigin... $ALLOWED_ORIGIN "
205225
206226 sed -i ' s/"_allowedOrigin"/"allowedOrigin"/' " $CONFIG_FILE "
207- jq --arg allowed_origin " $ALLOWED_ORIGIN " \
227+ jq --argjson allowed_origin " $ALLOWED_ORIGIN " \
208228 ' .domains[""].allowedOrigin = $allowed_origin' \
209229 " $CONFIG_FILE " > temp_config.json && mv temp_config.json " $CONFIG_FILE "
210230 else
0 commit comments