1414bashio::log.info " Starting MeshCentral..."
1515bashio::log.info " Hostname: ${HOSTNAME} "
1616bashio::log.info " Data path: ${DATA_PATH} "
17+ bashio::log.info " Cert URL: ${CERT_URL:- not set} "
1718
1819# Create data directory
1920mkdir -p " ${DATA_PATH} "
2021
21- # Generate config.json if it doesn't exist
2222CONFIG_FILE=" ${DATA_PATH} /config.json"
23+
24+ # Generate config.json if it doesn't exist
2325if [ ! -f " $CONFIG_FILE " ]; then
2426 bashio::log.info " Creating initial MeshCentral config..."
2527 cat > " $CONFIG_FILE " << EOF
@@ -43,7 +45,24 @@ if [ ! -f "$CONFIG_FILE" ]; then
4345 }
4446}
4547EOF
46- bashio::log.info " Config created. NOTE: Set 'newAccounts: true' temporarily to create your first admin account!"
48+ bashio::log.info " Config created."
49+ bashio::log.info " NOTE: Set 'newAccounts: true' temporarily to create your first admin account!"
50+ fi
51+
52+ # Always update certUrl from add-on options (even if config already existed)
53+ # This ensures changes to cert_url in HA options take effect on restart
54+ if command -v jq & > /dev/null; then
55+ if [ -n " $CERT_URL " ]; then
56+ bashio::log.info " Updating certUrl in config.json..."
57+ jq --arg url " $CERT_URL " ' .domains[""].certUrl = $url' " $CONFIG_FILE " > /tmp/mc_config_tmp.json \
58+ && mv /tmp/mc_config_tmp.json " $CONFIG_FILE "
59+ else
60+ bashio::log.info " No cert_url set — removing certUrl from config.json if present..."
61+ jq ' del(.domains[""].certUrl)' " $CONFIG_FILE " > /tmp/mc_config_tmp.json \
62+ && mv /tmp/mc_config_tmp.json " $CONFIG_FILE "
63+ fi
64+ else
65+ bashio::log.warning " jq not found — certUrl will only be set on first run. Install jq for dynamic updates."
4766fi
4867
4968# Start MeshCentral
0 commit comments