allow persistent mesh config and fix mongodb password uri issue
This commit is contained in:
parent
d2f63ef353
commit
bfa5b4fba5
|
@ -15,6 +15,7 @@ MESH_USER=tactical
|
|||
MESH_PASS=tactical
|
||||
MONGODB_USER=mongouser
|
||||
MONGODB_PASSWORD=mongopass
|
||||
MESH_PERSISTENT_CONFIG=0
|
||||
|
||||
# database settings
|
||||
POSTGRES_USER=postgres
|
||||
|
|
|
@ -9,14 +9,19 @@ set -e
|
|||
: "${MONGODB_HOST:=tactical-mongodb}"
|
||||
: "${MONGODB_PORT:=27017}"
|
||||
: "${NGINX_HOST_IP:=172.20.0.20}"
|
||||
: "${MESH_PERSISTENT_CONFIG:=0}"
|
||||
|
||||
mkdir -p /home/node/app/meshcentral-data
|
||||
mkdir -p ${TACTICAL_DIR}/tmp
|
||||
|
||||
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}')")
|
||||
|
||||
mesh_config="$(cat << EOF
|
||||
{
|
||||
"settings": {
|
||||
"mongodb": "mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@${MONGODB_HOST}:${MONGODB_PORT}",
|
||||
"mongodb": "${encoded_uri}",
|
||||
"Cert": "${MESH_HOST}",
|
||||
"TLSOffload": "${NGINX_HOST_IP}",
|
||||
"RedirPort": 80,
|
||||
|
@ -54,11 +59,19 @@ EOF
|
|||
|
||||
echo "${mesh_config}" > /home/node/app/meshcentral-data/config.json
|
||||
|
||||
fi
|
||||
|
||||
node node_modules/meshcentral --createaccount ${MESH_USER} --pass ${MESH_PASS} --email example@example.com
|
||||
node node_modules/meshcentral --adminaccount ${MESH_USER}
|
||||
|
||||
if [ ! -f "${TACTICAL_DIR}/tmp/mesh_token" ]; then
|
||||
node node_modules/meshcentral --logintokenkey > ${TACTICAL_DIR}/tmp/mesh_token
|
||||
mesh_token=$(node node_modules/meshcentral --logintokenkey)
|
||||
|
||||
if [[ ${#mesh_token} -eq 160 ]]; then
|
||||
echo ${mesh_token} > /opt/tactical/tmp/mesh_token
|
||||
else
|
||||
echo "Failed to generate mesh token. Fix the error and restart the mesh container"
|
||||
fi
|
||||
fi
|
||||
|
||||
# wait for nginx container
|
||||
|
|
|
@ -97,6 +97,7 @@ services:
|
|||
MESH_PASS: ${MESH_PASS}
|
||||
MONGODB_USER: ${MONGODB_USER}
|
||||
MONGODB_PASSWORD: ${MONGODB_PASSWORD}
|
||||
MESH_PERSISTENT_CONFIG: ${MESH_PERSISTENT_CONFIG}
|
||||
networks:
|
||||
proxy:
|
||||
aliases:
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
DOCKER_IMAGES="tactical tactical-frontend tactical-nats tactical-nginx tactical-meshcentral"
|
||||
# tactical tactical-frontend tactical-nats tactical-nginx
|
||||
DOCKER_IMAGES="tactical-meshcentral"
|
||||
|
||||
cd ..
|
||||
|
||||
|
|
Loading…
Reference in New Issue