Fix management .env to include CENTRAL_AUTH_SECRET/AUTH_URL; update add-app summary

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-01 19:34:16 +00:00
parent 53caeea318
commit ac846670f3
2 changed files with 17 additions and 9 deletions

View file

@ -219,13 +219,16 @@ pct push "$LXC_ID" "$ENV_TMP" "/opt/${APP_NAME}/.env" 2>/dev/null
rm -f "$ENV_TMP"
msg_ok ".env written"
# ── Register app in auth service ──────────────────────────────────────────────
msg_warn "Remember to register '${APP_NAME}' in the auth service DB:"
printf " docker exec hotel-manage-auth-1 node -e \"\n"
printf " const db = require('./src/db.js');\n"
printf " db.query(\\\"INSERT INTO apps (slug,name,base_path) VALUES ('%s','%s','%s') ON CONFLICT DO NOTHING\\\");\n" \
"$APP_NAME" "$APP_NAME" "$APP_PATH"
printf " \"\n\n"
# ── Register app in auth service DB ──────────────────────────────────────────
msg_info "Registering ${APP_NAME} in auth service"
pct exec 100 -- docker exec hotel-manage-postgres psql -U postgres -d auth_db -c \
"INSERT INTO apps (slug, name, description, base_path, icon, theme_color, internal_host, internal_port)
VALUES ('${APP_NAME}', '${APP_NAME^}', '', '${APP_PATH%/}', 'ClipboardList', '#1e3a5f', '10.10.10.${LAST_OCTET}', ${APP_PORT})
ON CONFLICT (slug) DO UPDATE SET
internal_host = '10.10.10.${LAST_OCTET}',
internal_port = ${APP_PORT};" &>/dev/null \
&& msg_ok "${APP_NAME} registered in auth DB (visible in portal after next login)" \
|| msg_warn "Auto-register failed — add ${APP_NAME} to the apps table in auth_db manually"
# ── NPM route reminder ────────────────────────────────────────────────────────
NPM_LAN="${NPM_LAN_IP:-<npm-lan-ip>}"
@ -246,7 +249,7 @@ cat <<SUMMARY
http://10.10.10.${LAST_OCTET}:${APP_PORT}${APP_PATH}health
4. Add Forgejo webhook:
http://10.10.10.105:9000/webhook (secret in /root/hotel-manage-credentials.txt)
5. Add deploy entry to the management repo: updater/deploy-map.js:
'${APP_NAME}': { host: '10.10.10.${LAST_OCTET}', path: '/opt/${APP_NAME}' }
5. App is auto-registered in auth DB — management picks it up within 5 minutes
(or immediately on next Forgejo webhook push)
SUMMARY

View file

@ -741,6 +741,9 @@ deploy_management() {
push_file 105 /opt/management/.env <<EOF
FORGEJO_WEBHOOK_SECRET=${WEBHOOK_SECRET}
WEBHOOK_SECRET=${WEBHOOK_SECRET}
CENTRAL_AUTH_SECRET=${CENTRAL_AUTH_SECRET}
AUTH_URL=http://10.10.10.101:3001
BACKUP_REMOTE=${BACKUP_REMOTE}
BACKUP_PG_HOST=10.10.10.100
BACKUP_PG_USER=postgres
@ -859,6 +862,8 @@ NODE_ENV=production
APP_SLUG=cashup
DATABASE_URL=postgresql://cashup:${CASHUP_DB_PASS}@10.10.10.100:5432/cashup_db
CENTRAL_AUTH_SECRET=${CENTRAL_AUTH_SECRET}
SETTINGS_URL=http://10.10.10.116:3080
SETTINGS_SECRET=${SETTINGS_SECRET}
OFFICE_IP_CHECK=${OFFICE_IP_CHECK:-${OFFICE_IP:-disabled}}
FRONTEND_PORT=3083
EOF