Add settings service to stack installer
Add LXC 116 (settings) to install-stack.sh: generates SETTINGS_DB_PASS and SETTINGS_SECRET, creates settings_db in postgres init SQL, provisions the LXC and deploys the service. Step counter updated to 7/7. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f6cb86809f
commit
fde4fa3115
1 changed files with 58 additions and 8 deletions
|
|
@ -28,7 +28,7 @@ header_info() {
|
|||
cat <<'BANNER'
|
||||
╔══════════════════════════════════════════════════════════════╗
|
||||
║ HOTEL MANAGE — PROXMOX STACK INSTALLER ║
|
||||
║ postgres · auth · portal · npm · mgmt · noticeboard ║
|
||||
║ postgres · auth · portal · npm · mgmt · noticeboard · settings ║
|
||||
╚══════════════════════════════════════════════════════════════╝
|
||||
BANNER
|
||||
printf "${CL}\n"
|
||||
|
|
@ -231,11 +231,12 @@ Example: backup@192.168.1.10:/backups/hotel-manage" \
|
|||
103 hotel-manage-npm 10.10.10.103 / ${NPM_LAN_IP} (dual-homed)
|
||||
105 hotel-manage-management 10.10.10.105
|
||||
112 hotel-manage-noticeboard 10.10.10.112
|
||||
116 hotel-manage-settings 10.10.10.116
|
||||
|
||||
Domain: ${DOMAIN}
|
||||
Admin: ${ADMIN_EMAIL}
|
||||
|
||||
Proceed?" 24 58 || exit 0
|
||||
Proceed?" 26 58 || exit 0
|
||||
}
|
||||
|
||||
# ── Generate secrets ──────────────────────────────────────────────────────────
|
||||
|
|
@ -248,7 +249,9 @@ gen_secrets() {
|
|||
PG_SUPERPASS=$(sed -n 's/^PG_SUPERPASS=//p' "$CREDS_FILE" | head -1)
|
||||
AUTH_DB_PASS=$(sed -n 's/^AUTH_DB_PASS=//p' "$CREDS_FILE" | head -1)
|
||||
NOTICES_DB_PASS=$(sed -n 's/^NOTICES_DB_PASS=//p' "$CREDS_FILE" | head -1)
|
||||
SETTINGS_DB_PASS=$(sed -n 's/^SETTINGS_DB_PASS=//p' "$CREDS_FILE" | head -1)
|
||||
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_ADMIN_PASS=$(sed -n 's/^NPM_ADMIN_PASS=//p' "$CREDS_FILE" | head -1)
|
||||
msg_ok "Reusing existing secrets"
|
||||
|
|
@ -259,7 +262,9 @@ gen_secrets() {
|
|||
PG_SUPERPASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
||||
AUTH_DB_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
||||
NOTICES_DB_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
||||
SETTINGS_DB_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
||||
CENTRAL_AUTH_SECRET=$(openssl rand -hex 32)
|
||||
SETTINGS_SECRET=$(openssl rand -hex 32)
|
||||
WEBHOOK_SECRET=$(openssl rand -hex 24)
|
||||
NPM_ADMIN_PASS=$(openssl rand -base64 12 | tr -dc 'a-zA-Z0-9' | head -c 12)
|
||||
|
||||
|
|
@ -276,7 +281,9 @@ OFFICE_IP_CHECK=${OFFICE_IP}
|
|||
PG_SUPERPASS=${PG_SUPERPASS}
|
||||
AUTH_DB_PASS=${AUTH_DB_PASS}
|
||||
NOTICES_DB_PASS=${NOTICES_DB_PASS}
|
||||
SETTINGS_DB_PASS=${SETTINGS_DB_PASS}
|
||||
CENTRAL_AUTH_SECRET=${CENTRAL_AUTH_SECRET}
|
||||
SETTINGS_SECRET=${SETTINGS_SECRET}
|
||||
WEBHOOK_SECRET=${WEBHOOK_SECRET}
|
||||
|
||||
NPM_ADMIN_EMAIL=admin@${DOMAIN}
|
||||
|
|
@ -502,7 +509,7 @@ wait_pg() {
|
|||
# PHASE 1 — POSTGRES LXC 100
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
deploy_postgres() {
|
||||
msg_step "1/6 Postgres (LXC 100 · 10.10.10.100)"
|
||||
msg_step "1/7 Postgres (LXC 100 · 10.10.10.100)"
|
||||
|
||||
msg_info "Creating LXC 100"
|
||||
create_lxc 100 "10.10.10.100" "postgres" 512 1
|
||||
|
|
@ -559,6 +566,14 @@ CREATE USER noticeboard WITH PASSWORD '${NOTICES_DB_PASS}';
|
|||
CREATE DATABASE noticeboard_db OWNER noticeboard;
|
||||
\c noticeboard_db
|
||||
GRANT ALL ON SCHEMA public TO noticeboard;
|
||||
EOF
|
||||
|
||||
# Init SQL — settings DB
|
||||
push_file 100 /opt/postgres/init/03-settings.sql <<EOF
|
||||
CREATE USER settings WITH PASSWORD '${SETTINGS_DB_PASS}';
|
||||
CREATE DATABASE settings_db OWNER settings;
|
||||
\c settings_db
|
||||
GRANT ALL ON SCHEMA public TO settings;
|
||||
EOF
|
||||
|
||||
pct exec 100 -- bash -c "cd /opt/postgres && docker compose up -d" &>/dev/null
|
||||
|
|
@ -573,7 +588,7 @@ EOF
|
|||
# PHASE 2 — AUTH SERVICE LXC 101
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
deploy_auth() {
|
||||
msg_step "2/6 Auth service (LXC 101 · 10.10.10.101)"
|
||||
msg_step "2/7 Auth service (LXC 101 · 10.10.10.101)"
|
||||
|
||||
msg_info "Creating LXC 101"
|
||||
create_lxc 101 "10.10.10.101" "auth" 1024 1
|
||||
|
|
@ -612,7 +627,7 @@ EOF
|
|||
# PHASE 3 — PORTAL LXC 102
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
deploy_portal() {
|
||||
msg_step "3/6 Portal (LXC 102 · 10.10.10.102)"
|
||||
msg_step "3/7 Portal (LXC 102 · 10.10.10.102)"
|
||||
|
||||
msg_info "Creating LXC 102"
|
||||
create_lxc 102 "10.10.10.102" "portal" 1024 2
|
||||
|
|
@ -646,7 +661,7 @@ EOF
|
|||
# PHASE 4 — NPM LXC 103 (dual-homed)
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
deploy_npm() {
|
||||
msg_step "4/6 Nginx Proxy Manager (LXC 103 · ${NPM_LAN_IP} / 10.10.10.3)"
|
||||
msg_step "4/7 Nginx Proxy Manager (LXC 103 · ${NPM_LAN_IP} / 10.10.10.3)"
|
||||
|
||||
msg_info "Creating NPM LXC 103 (dual-homed)"
|
||||
create_npm_lxc
|
||||
|
|
@ -695,7 +710,7 @@ EOF
|
|||
# PHASE 5 — MANAGEMENT LXC 105
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
deploy_management() {
|
||||
msg_step "5/6 Management (LXC 105 · 10.10.10.105)"
|
||||
msg_step "5/7 Management (LXC 105 · 10.10.10.105)"
|
||||
|
||||
msg_info "Creating LXC 105"
|
||||
create_lxc 105 "10.10.10.105" "management" 1024 1
|
||||
|
|
@ -735,7 +750,7 @@ EOF
|
|||
# PHASE 6 — NOTICEBOARD LXC 112
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
deploy_noticeboard() {
|
||||
msg_step "6/6 Noticeboard (LXC 112 · 10.10.10.112)"
|
||||
msg_step "6/7 Noticeboard (LXC 112 · 10.10.10.112)"
|
||||
|
||||
msg_info "Creating LXC 112"
|
||||
create_lxc 112 "10.10.10.112" "noticeboard" 1024 1
|
||||
|
|
@ -765,6 +780,39 @@ EOF
|
|||
|| msg_warn "Noticeboard may need extra time — check LXC 112"
|
||||
}
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
# PHASE 7 — SETTINGS SERVICE LXC 116
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
deploy_settings() {
|
||||
msg_step "7/7 Settings service (LXC 116 · 10.10.10.116)"
|
||||
|
||||
msg_info "Creating LXC 116"
|
||||
create_lxc 116 "10.10.10.116" "settings" 512 1
|
||||
msg_ok "LXC 116 created"
|
||||
|
||||
msg_info "Installing Docker"
|
||||
install_docker 116
|
||||
install_mgmt_key 116
|
||||
msg_ok "Docker + SSH ready"
|
||||
|
||||
msg_info "Deploying settings service"
|
||||
deploy_service 116 "settings" "${REPO_ROOT}/settings" /opt/settings
|
||||
|
||||
push_file 116 /opt/settings/.env <<EOF
|
||||
NODE_ENV=production
|
||||
DATABASE_URL=postgresql://settings:${SETTINGS_DB_PASS}@10.10.10.100:5432/settings_db
|
||||
SETTINGS_SECRET=${SETTINGS_SECRET}
|
||||
AUTH_URL=http://10.10.10.101:3001
|
||||
EOF
|
||||
|
||||
pct exec 116 -- bash -c "cd /opt/settings && docker compose up -d --build" &>/dev/null
|
||||
|
||||
msg_info "Waiting for settings service"
|
||||
wait_healthy 116 "http://localhost:3080/health" \
|
||||
&& msg_ok "Settings service running at 10.10.10.116:3080" \
|
||||
|| msg_warn "Settings may need extra time — check LXC 116"
|
||||
}
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
# NPM PROXY HOSTS (via API)
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
|
|
@ -863,6 +911,7 @@ SUMMARY
|
|||
105 hotel-manage-management 10.10.10.105 3002 Uptime Kuma
|
||||
9000 Forgejo webhooks
|
||||
112 hotel-manage-noticeboard 10.10.10.112 3080 /notices/
|
||||
116 hotel-manage-settings 10.10.10.116 3080 /settings/api/
|
||||
|
||||
── Credentials ───────────────────────────────────────────────
|
||||
Admin login: ${ADMIN_EMAIL}
|
||||
|
|
@ -909,5 +958,6 @@ deploy_portal
|
|||
deploy_npm
|
||||
deploy_management
|
||||
deploy_noticeboard
|
||||
deploy_settings
|
||||
configure_npm_proxy_hosts
|
||||
print_summary
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue