feat: add room-planner to --only deploy (LXC 120)
Adds deploy_room_planner() function for LXC 120 / 10.10.10.120. Wires it into --only room-planner, postgres init SQL (07-room-planner.sql), gen_secrets, credentials file template, and the main deploy sequence. NEWBOOK_LOCATION_ID written to .env with a warning if unset. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a35deb40bf
commit
7758e67f5b
1 changed files with 81 additions and 1 deletions
|
|
@ -253,6 +253,7 @@ gen_secrets() {
|
|||
CASHUP_DB_PASS=$(sed -n 's/^CASHUP_DB_PASS=//p' "$CREDS_FILE" | head -1)
|
||||
HK_PLANNER_DB_PASS=$(sed -n 's/^HK_PLANNER_DB_PASS=//p' "$CREDS_FILE" | head -1)
|
||||
TWIN_OPT_DB_PASS=$(sed -n 's/^TWIN_OPT_DB_PASS=//p' "$CREDS_FILE" | head -1)
|
||||
ROOM_PLANNER_DB_PASS=$(sed -n 's/^ROOM_PLANNER_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)
|
||||
|
|
@ -271,6 +272,7 @@ gen_secrets() {
|
|||
CASHUP_DB_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
||||
HK_PLANNER_DB_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
||||
TWIN_OPT_DB_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
||||
ROOM_PLANNER_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)
|
||||
|
|
@ -293,6 +295,7 @@ SETTINGS_DB_PASS=${SETTINGS_DB_PASS}
|
|||
CASHUP_DB_PASS=${CASHUP_DB_PASS}
|
||||
HK_PLANNER_DB_PASS=${HK_PLANNER_DB_PASS}
|
||||
TWIN_OPT_DB_PASS=${TWIN_OPT_DB_PASS}
|
||||
ROOM_PLANNER_DB_PASS=${ROOM_PLANNER_DB_PASS}
|
||||
CENTRAL_AUTH_SECRET=${CENTRAL_AUTH_SECRET}
|
||||
SETTINGS_SECRET=${SETTINGS_SECRET}
|
||||
WEBHOOK_SECRET=${WEBHOOK_SECRET}
|
||||
|
|
@ -621,6 +624,14 @@ CREATE USER twin_optimiser WITH PASSWORD '${TWIN_OPT_DB_PASS}';
|
|||
CREATE DATABASE twin_optimiser_db OWNER twin_optimiser;
|
||||
\c twin_optimiser_db
|
||||
GRANT ALL ON SCHEMA public TO twin_optimiser;
|
||||
EOF
|
||||
|
||||
# Init SQL — room-planner DB
|
||||
push_file 100 /opt/postgres/init/07-room-planner.sql <<EOF
|
||||
CREATE USER room_planner WITH PASSWORD '${ROOM_PLANNER_DB_PASS}';
|
||||
CREATE DATABASE room_planner_db OWNER room_planner;
|
||||
\c room_planner_db
|
||||
GRANT ALL ON SCHEMA public TO room_planner;
|
||||
EOF
|
||||
|
||||
pct exec 100 -- bash -c "cd /opt/postgres && docker compose up -d" &>/dev/null
|
||||
|
|
@ -1061,6 +1072,73 @@ ${build_out}"
|
|||
npm_add_location "/twin-optimiser/" "10.10.10.119" 3080
|
||||
}
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
# PHASE 11 — ROOM PLANNER LXC 120
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
deploy_room_planner() {
|
||||
msg_step "11/11 Room Planner (LXC 120 · 10.10.10.120)"
|
||||
|
||||
if [[ -z "${ROOM_PLANNER_DB_PASS:-}" ]]; then
|
||||
ROOM_PLANNER_DB_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
||||
printf '\nROOM_PLANNER_DB_PASS=%s\n' "$ROOM_PLANNER_DB_PASS" >> "$CREDS_FILE"
|
||||
msg_ok "Generated ROOM_PLANNER_DB_PASS → ${CREDS_FILE}"
|
||||
fi
|
||||
|
||||
msg_info "Creating LXC 120"
|
||||
create_lxc 120 "10.10.10.120" "room-planner" 1024 1
|
||||
msg_ok "LXC 120 created"
|
||||
|
||||
msg_info "Installing Docker"
|
||||
install_docker 120
|
||||
install_mgmt_key 120
|
||||
msg_ok "Docker + SSH ready"
|
||||
|
||||
msg_info "Creating room_planner database"
|
||||
pct exec 100 -- bash -c "
|
||||
docker exec hotel-manage-postgres psql -U postgres -c \
|
||||
\"CREATE USER room_planner WITH PASSWORD '${ROOM_PLANNER_DB_PASS}';\" 2>/dev/null || true
|
||||
docker exec hotel-manage-postgres psql -U postgres -c \
|
||||
\"CREATE DATABASE room_planner_db OWNER room_planner;\" 2>/dev/null || true
|
||||
docker exec hotel-manage-postgres psql -U postgres -d room_planner_db -c \
|
||||
\"GRANT ALL ON SCHEMA public TO room_planner;\" 2>/dev/null || true
|
||||
" &>/dev/null
|
||||
msg_ok "Database room_planner_db ready"
|
||||
|
||||
msg_info "Deploying room-planner"
|
||||
deploy_service 120 "room-planner" "${REPO_ROOT}/room-planner" /opt/room-planner
|
||||
|
||||
# NEWBOOK_LOCATION_ID is the NewBook property location ID — set in credentials file if known
|
||||
local nb_location="${NEWBOOK_LOCATION_ID:-}"
|
||||
[[ -z "$nb_location" ]] && msg_warn "NEWBOOK_LOCATION_ID not set — add it to /opt/room-planner/.env on LXC 120"
|
||||
|
||||
push_file 120 /opt/room-planner/.env <<EOF
|
||||
NODE_ENV=production
|
||||
APP_SLUG=room-planner
|
||||
DATABASE_URL=postgresql://room_planner:${ROOM_PLANNER_DB_PASS}@10.10.10.100:5432/room_planner_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}}
|
||||
NEWBOOK_LOCATION_ID=${nb_location}
|
||||
DEFAULT_CHECKOUT_TIME=11:00
|
||||
FRONTEND_PORT=3080
|
||||
EOF
|
||||
|
||||
local build_out
|
||||
if ! build_out=$(pct exec 120 -- bash -c "cd /opt/room-planner && docker compose up -d --build 2>&1"); then
|
||||
msg_error "docker compose build failed in LXC 120:
|
||||
${build_out}"
|
||||
fi
|
||||
|
||||
msg_info "Waiting for room-planner"
|
||||
wait_healthy 120 "http://localhost:3080/room-planner/health" \
|
||||
&& msg_ok "Room Planner running at 10.10.10.120:3080" \
|
||||
|| msg_warn "Room Planner may need extra time — check LXC 120"
|
||||
|
||||
# Add /room-planner/ location to NPM proxy host
|
||||
npm_add_location "/room-planner/" "10.10.10.120" 3080
|
||||
}
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
# NPM PROXY HOSTS (via API)
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
|
|
@ -1309,7 +1387,7 @@ SUMMARY
|
|||
# Sources existing credentials and redeploys just the named service.
|
||||
if [[ "${1:-}" == "--only" ]]; then
|
||||
ONLY="${2:-}"
|
||||
VALID="postgres auth portal npm management noticeboard settings cashup hk-planner twin-optimiser"
|
||||
VALID="postgres auth portal npm management noticeboard settings cashup hk-planner twin-optimiser room-planner"
|
||||
[[ -z "$ONLY" ]] && msg_error "Usage: install-stack.sh --only <service> (one of: ${VALID})"
|
||||
grep -qw "$ONLY" <<< "$VALID" || msg_error "Unknown service '${ONLY}'. Valid: ${VALID}"
|
||||
CREDS_FILE=/root/hotel-manage-credentials.txt
|
||||
|
|
@ -1352,6 +1430,7 @@ if [[ "${1:-}" == "--only" ]]; then
|
|||
cashup) deploy_cashup ;;
|
||||
hk-planner) deploy_hk_planner ;;
|
||||
twin-optimiser) deploy_twin_optimiser ;;
|
||||
room-planner) deploy_room_planner ;;
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
|
@ -1372,5 +1451,6 @@ deploy_settings
|
|||
deploy_cashup
|
||||
deploy_hk_planner
|
||||
deploy_twin_optimiser
|
||||
deploy_room_planner
|
||||
configure_npm_proxy_hosts
|
||||
print_summary
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue