diff --git a/install-stack.sh b/install-stack.sh index 2e109dc..67ab592 100755 --- a/install-stack.sh +++ b/install-stack.sh @@ -254,6 +254,7 @@ gen_secrets() { CENTRAL_AUTH_SECRET=$(sed -n 's/^CENTRAL_AUTH_SECRET=//p' "$CREDS_FILE" | head -1) SETTINGS_SECRET=$(sed -n 's/^SETTINGS_SECRET=//p' "$CREDS_FILE" | head -1) WEBHOOK_SECRET=$(sed -n 's/^WEBHOOK_SECRET=//p' "$CREDS_FILE" | head -1) + NPM_LAN_IP=$(sed -n 's/^NPM_LAN_IP=//p' "$CREDS_FILE" | head -1) NPM_ADMIN_EMAIL=$(sed -n 's/^NPM_ADMIN_EMAIL=//p' "$CREDS_FILE" | head -1) NPM_ADMIN_PASS=$(sed -n 's/^NPM_ADMIN_PASS=//p' "$CREDS_FILE" | head -1) msg_ok "Reusing existing secrets" @@ -290,6 +291,7 @@ CENTRAL_AUTH_SECRET=${CENTRAL_AUTH_SECRET} SETTINGS_SECRET=${SETTINGS_SECRET} WEBHOOK_SECRET=${WEBHOOK_SECRET} +NPM_LAN_IP=${NPM_LAN_IP} NPM_ADMIN_EMAIL=manage@hotel.com NPM_ADMIN_PASS=${NPM_ADMIN_PASS} @@ -905,7 +907,7 @@ ${build_out}" fi msg_info "Waiting for cashup" - wait_healthy 117 "http://localhost:3083/cashup/api/health" \ + wait_healthy 117 "http://localhost:3083/cashup/health" \ && msg_ok "Cashup running at 10.10.10.117:3083" \ || msg_warn "Cashup may need extra time — check LXC 117" @@ -914,10 +916,11 @@ ${build_out}" local npm_token npm_token=$(npm_get_token) + local npm_ip="${NPM_LAN_IP:-10.10.10.103}" if [[ -n "$npm_token" ]]; then # Find the proxy host for our domain local host_id - host_id=$(curl -sf "http://${NPM_LAN_IP}:81/api/nginx/proxy-hosts" \ + host_id=$(curl -sf "http://${npm_ip}:81/api/nginx/proxy-hosts" \ -H "Authorization: Bearer ${npm_token}" 2>/dev/null \ | grep -o '"id":[0-9]*,"domain_names":\["'"${DOMAIN}"'"\]' \ | grep -o '"id":[0-9]*' | cut -d: -f2) || true @@ -925,7 +928,7 @@ ${build_out}" if [[ -n "$host_id" ]]; then # Fetch existing host, merge /cashup/ location, PUT back local existing - existing=$(curl -sf "http://${NPM_LAN_IP}:81/api/nginx/proxy-hosts/${host_id}" \ + existing=$(curl -sf "http://${npm_ip}:81/api/nginx/proxy-hosts/${host_id}" \ -H "Authorization: Bearer ${npm_token}" 2>/dev/null) || true if [[ -n "$existing" ]] && ! echo "$existing" | grep -q '"/cashup/"'; then @@ -940,7 +943,7 @@ print(json.dumps(locs)) " 2>/dev/null) || true if [[ -n "$merged_locations" ]]; then - curl -sf -X PUT "http://${NPM_LAN_IP}:81/api/nginx/proxy-hosts/${host_id}" \ + curl -sf -X PUT "http://${npm_ip}:81/api/nginx/proxy-hosts/${host_id}" \ -H "Authorization: Bearer ${npm_token}" \ -H "Content-Type: application/json" \ -d "{\"locations\":${merged_locations}}" &>/dev/null \ @@ -964,10 +967,11 @@ print(json.dumps(locs)) # Returns a Bearer token for the NPM API, or empty string on failure. npm_get_token() { + local npm_ip="${NPM_LAN_IP:-10.10.10.103}" local email="${NPM_ADMIN_EMAIL:-manage@hotel.com}" local pass="${NPM_ADMIN_PASS:-}" [[ -z "$pass" ]] && { echo ""; return; } - curl -sf -X POST "http://${NPM_LAN_IP}:81/api/tokens" \ + curl -sf -X POST "http://${npm_ip}:81/api/tokens" \ -H "Content-Type: application/json" \ -d "{\"identity\":\"${email}\",\"secret\":\"${pass}\"}" \ 2>/dev/null | grep -o '"token":"[^"]*"' | cut -d'"' -f4 || echo ""