From f61329b5de1bb03ce95c3534126b6b1adb3839de Mon Sep 17 00:00:00 2001 From: sadnub Date: Tue, 1 Feb 2022 22:15:08 -0500 Subject: [PATCH] update mesh ports for persistent mesh configuration --- docker/containers/tactical-meshcentral/dockerfile | 3 +-- docker/containers/tactical-meshcentral/entrypoint.sh | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docker/containers/tactical-meshcentral/dockerfile b/docker/containers/tactical-meshcentral/dockerfile index e9156a77..d0b3f5ed 100644 --- a/docker/containers/tactical-meshcentral/dockerfile +++ b/docker/containers/tactical-meshcentral/dockerfile @@ -10,8 +10,7 @@ SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"] COPY api/tacticalrmm/tacticalrmm/settings.py /tmp/settings.py -RUN grep -o 'MESH_VER.*' /tmp/settings.py | cut -d'"' -f 2 > /tmp/MESH_VER && \ - npm install meshcentral@$(cat /tmp/MESH_VER) +RUN npm install meshcentral@$(grep -o 'MESH_VER.*' /tmp/settings.py | cut -d'"' -f 2) RUN chown -R node:node /home/node diff --git a/docker/containers/tactical-meshcentral/entrypoint.sh b/docker/containers/tactical-meshcentral/entrypoint.sh index b0e6c172..b13acd1d 100644 --- a/docker/containers/tactical-meshcentral/entrypoint.sh +++ b/docker/containers/tactical-meshcentral/entrypoint.sh @@ -21,9 +21,9 @@ set -e if [ ! -f "/home/node/app/meshcentral-data/config.json" ] || [[ "${MESH_PERSISTENT_CONFIG}" -eq 0 ]]; then -encoded_uri=$(node -p "encodeURI('mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@${MONGODB_HOST}:${MONGODB_PORT}')") + encoded_uri=$(node -p "encodeURI('mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@${MONGODB_HOST}:${MONGODB_PORT}')") -mesh_config="$(cat << EOF + mesh_config="$(cat << EOF { "settings": { "mongodb": "${encoded_uri}", @@ -71,7 +71,13 @@ mesh_config="$(cat << EOF EOF )" -echo "${mesh_config}" > /home/node/app/meshcentral-data/config.json + echo "${mesh_config}" > /home/node/app/meshcentral-data/config.json + +else + # replace persistent mesh configuration with new ports + sed -i 's/"Port": 443/"Port": 4443/' /home/node/app/meshcentral-data/config.json + sed -i 's/"RedirPort": 80/"RedirPort": 8080/' /home/node/app/meshcentral-data/config.json + sed -i "s/\"CertUrl\": \".*\"/\"CertUrl\": \"https:\/\/${NGINX_HOST_IP}:${NGINX_HOST_PORT}\"/" /home/node/app/meshcentral-data/config.json fi