More work done on the logic. mongoDB url editing works.
Daan committed
Mar 22, 2025 at 02:10 UTC
59194abc276ca847b8189ebbffd805855dee2139
2 files changed
+26
-8
.gitignore
+2
-1
@@ -310,4 +310,5 @@ __pycache__/
310
311
# When running mkdocs locally as dev
312
docs/__pycache__/
313
-docs/env/
\ No newline at end of file
313
+docs/env/
314
+docker-compose.yaml
docker/entrypoint.sh
+24
-7
@@ -22,22 +22,29 @@ fi
22
if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
23
24
if [[ "$USE_MONGODB" =~ ^(true|yes)$ ]]; then
25
- if [[ -n "$MONGO_URL" ]]; 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"
28
+ MONGO_URL="${MONGO_URL:-$MONGO_USERNAME:$MONGO_PASS@}$MONGO_HOST:$MONGO_PORT"
29
fi
30
- sed -i "s/\"?_mongoDb\": \"\"/\"mongoDb\": \"$MONGO_URL\"/" "$CONFIG_FILE"
30
+
31
+ ESCAPED_MONGO_URL=$(echo "$MONGO_URL" | sed 's/[\/&?=:]/\\&/g')
32
+ sed -i 's/"_mongoDb"/"mongoDb"/' "$CONFIG_FILE"
33
+ sed -i "s/\"mongoDb\": *\"[^\"]*\"/\"mongoDb\": \"$ESCAPED_MONGO_URL\"/" "$CONFIG_FILE"
34
else
32
- sed -i 's/"?_mongoDb": ""/"_mongoDb": "null"/' "$CONFIG_FILE"
35
+ sed -i 's/"mongoDb"/"_mongoDb"/' "$CONFIG_FILE"
36
fi
37
38
if [[ "$USE_POSTGRESQL" =~ ^(true|yes)$ ]]; then
36
- echo "So you wanna postgrsex"
39
+ echo "So you wanna postgres"
40
+ else
41
+ echo "No Postgres"
42
fi
43
44
if [[ "$USE_MARIADB" =~ ^(true|yes)$ ]]; then
40
- echo "So you wanna Maria-Dick-Big"
45
+ echo "So you wanna MariaDB"
46
+ else
47
+ echo "No MariaDB"
48
fi
49
50
# Doing the bulk with JQ utility. Given the remaining variables an opportunity with Sed.
@@ -50,7 +57,9 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
57
# SESSIONKEY
58
if [[ $REGENSESSIONKEY =~ ^(true|yes)$ ]]; then
59
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)
60
+ SESSION_KEY=$(tr -dc 'A-Z0-9' < /dev/urandom | fold -w 96 | head -n 1)
61
+
62
+ sed -i 's/"_sessionKey"/"sessionKey"/' "$CONFIG_FILE"
63
sed -i "s/\"sessionKey\": *\"[^\"]*\"/\"sessionKey\": \"$SESSION_KEY\"/" "$CONFIG_FILE"
64
else
65
echo "REGENSESSIONKEY is not 'true' or 'yes', therefore it's being kept as is."
@@ -59,6 +68,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
68
# HOSTNAME
69
if [[ -n $HOSTNAME ]] && [[ $HOSTNAME =~ ^([a-zA-Z0-9-]+\.)+[a-zA-Z0-9-]+$ ]]; then
70
echo "Setting hostname (cert)... - $HOSTNAME"
71
+ sed -i 's/"_cert"/"cert"/' "$CONFIG_FILE"
72
sed -i "s/\"cert\": *\"[^\"]*\"/\"cert\": \"$HOSTNAME\"/" "$CONFIG_FILE"
73
else
74
echo "Invalid hostname, commenting it out..."
@@ -68,6 +78,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
78
# ALLOW_NEW_ACCOUNTS
79
if [[ -n $ALLOW_NEW_ACCOUNTS ]] && [[ $ALLOW_NEW_ACCOUNTS =~ ^(true|false)$ ]]; then
80
echo "Setting NewAccounts... - $ALLOW_NEW_ACCOUNTS"
81
+ sed -i 's/"_NewAccounts"/"NewAccounts"/' "$CONFIG_FILE"
82
sed -i "s/\"NewAccounts\": *[a-z]*/\"NewAccounts\": $ALLOW_NEW_ACCOUNTS/" "$CONFIG_FILE"
83
else
84
echo "Invalid ALLOW_NEW_ACCOUNTS value given, commenting out so default applies..."
@@ -77,6 +88,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
88
# ALLOWPLUGINS
89
if [[ -n $ALLOWPLUGINS ]] && [[ $ALLOWPLUGINS =~ ^(true|false)$ ]]; then
90
echo "Setting plugins... - $ALLOWPLUGINS"
91
+ sed -i 's/"_plugins"/"plugins"/' "$CONFIG_FILE"
92
sed -i "s/\"plugins\": *{[^}]*}/\"plugins\": {\"enabled\": $ALLOWPLUGINS}/" "$CONFIG_FILE"
93
else
94
echo "Invalid ALLOWPLUGINS value given, commenting out so default applies..."
@@ -86,6 +98,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
98
# LOCALSESSIONRECORDING
99
if [[ -n $LOCALSESSIONRECORDING ]] && [[ $LOCALSESSIONRECORDING =~ ^(true|false)$ ]]; then
100
echo "Setting localSessionRecording... - $LOCALSESSIONRECORDING"
101
+ sed -i 's/"_localSessionRecording"/"localSessionRecording"/' "$CONFIG_FILE"
102
sed -i "s/\"localSessionRecording\": *[a-z]*/\"localSessionRecording\": $LOCALSESSIONRECORDING/" "$CONFIG_FILE"
103
else
104
echo "Invalid LOCALSESSIONRECORDING value given, commenting out so default applies..."
@@ -95,6 +108,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
108
# MINIFY
109
if [[ -n $MINIFY ]] && [[ $MINIFY =~ ^(true|false)$ ]]; then
110
echo "Setting minify... - $MINIFY"
111
+ sed -i 's/"_minify"/"minify"/' "$CONFIG_FILE"
112
sed -i "s/\"minify\": *[a-z]*/\"minify\": $MINIFY/" "$CONFIG_FILE"
113
else
114
echo "Invalid MINIFY value given, commenting out so default applies..."
@@ -104,6 +118,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
118
# WEBRTC
119
if [[ -n $WEBRTC ]] && [[ $WEBRTC =~ ^(true|false)$ ]]; then
120
echo "Setting WebRTC... - $WEBRTC"
121
+ sed -i 's/"_WebRTC"/"WebRTC"/' "$CONFIG_FILE"
122
sed -i "s/\"WebRTC\": *[a-z]*/\"WebRTC\": $WEBRTC/" "$CONFIG_FILE"
123
else
124
echo "Invalid WEBRTC value given, commenting out so default applies..."
@@ -113,6 +128,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
128
# IFRAME
129
if [[ -n $IFRAME ]] && [[ $IFRAME =~ ^(true|false)$ ]]; then
130
echo "Setting AllowFraming... - $IFRAME"
131
+ sed -i 's/"_AllowFraming"/"AllowFraming"/' "$CONFIG_FILE"
132
sed -i "s/\"AllowFraming\": *[a-z]*/\"AllowFraming\": $IFRAME/" "$CONFIG_FILE"
133
else
134
echo "Invalid IFRAME value given, commenting out so default applies..."
@@ -122,6 +138,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
138
# ALLOWED_ORIGIN
139
if [[ -n $ALLOWED_ORIGIN ]] && [[ $ALLOWED_ORIGIN =~ ^(true|false)$ ]]; then
140
echo "Setting allowedOrigin... - $ALLOWED_ORIGIN"
141
+ sed -i 's/"_allowedOrigin"/"allowedOrigin"/' "$CONFIG_FILE"
142
sed -i "s/\"allowedOrigin\": *[a-z]*/\"allowedOrigin\": $ALLOWED_ORIGIN/" "$CONFIG_FILE"
143
else
144
echo "Invalid ALLOWED_ORIGIN value given, commenting out so default applies..."