Use jq with mongo.
Daan committed
Mar 23, 2025 at 22:45 UTC
51ad698213ba20a0c0649ee9ffd9a3844fba7d4d
2 files changed
+4
-31
docker/BUILD.md
deleted
-29
@@ -1,29 +0,0 @@
1
-# How to create a docker image for meshcentral
2
-
3
-```
4
-> git clone https://github.com/Ylianst/MeshCentral.git
5
-> cd MeshCentral
6
-
7
-> docker build -f docker/Dockerfile --force-rm -t meshcentral .
8
-
9
-# alternative, if you want to include the mongodb-tools (mongodump, ...), you can add the 'INCLUDE_MONGODBTOOLS=yes' build argument
10
-> docker build -f docker/Dockerfile --force-rm --build-arg INCLUDE_MONGODBTOOLS=yes -t meshcentral .
11
-
12
-# (optional) cleanup after docker build:
13
-> cd ..
14
-> rm -rf MeshCentral/
15
-```
16
-
17
-> | Argument | Description |
18
-> | :--- | :--- |
19
-> | -f docker/Dockerfile | Path/Name of the Dockerfile |
20
-> | --force-rm | Always remove intermediate containers |
21
-> | -t meshcentral | Name and optionally a tag in the 'name:tag' format |
22
-
23
-### Optional build arguments
24
-> | Argument | Description |
25
-> | :--- | :--- |
26
-> | INCLUDE_MONGODBTOOLS=yes | Includes mongodb-tools (mongodump, ...) in the image |
27
-> | DISABLE_MINIFY=yes | Disables the minification of files |
28
-> | DISABLE_TRANSLATE=yes | Disables the translation of files |
29
-
docker/entrypoint.sh
+4
-2
@@ -35,9 +35,11 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
35
MONGO_URL="${MONGO_URL:-$MONGO_USERNAME:$MONGO_PASS@}$MONGO_HOST:$MONGO_PORT"
36
fi
37
38
- ESCAPED_MONGO_URL=$(echo "$MONGO_URL" | sed 's/[\/&?=:]/\\&/g')
38
+ #ESCAPED_MONGO_URL=$(echo "$MONGO_URL" | sed 's/[\/&?=:]/\\&/g')
39
sed -i 's/"_mongoDb"/"mongoDb"/' "$CONFIG_FILE"
40
- sed -i "s/\"mongoDb\": *\"[^\"]*\"/\"mongoDb\": \"$ESCAPED_MONGO_URL\"/" "$CONFIG_FILE"
40
+ jq --arg mongo_url "$MONGO_URL" \
41
+ '.settings.mongoDb = $mongo_url' \
42
+ "$CONFIG_FILE" > temp_config.json && mv temp_config.json "$CONFIG_FILE"
43
else
44
echo "Disabling MongoDB-connector..."
45
sed -i 's/"mongoDb"/"_mongoDb"/' "$CONFIG_FILE"