Files
solace-bg-dubai/scripts/proxmox-prepare-env.sh
defiQUG a03417be98
All checks were successful
CI / lint-and-test (push) Successful in 9m52s
chore: consolidate local WIP (repo cleanup 20260707)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 09:41:38 -07:00

47 lines
1.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Prepare backend/frontend env files for Proxmox CT IPs (192.168.11.6063).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
DB_HOST="${DATABASE_IP:-192.168.11.62}"
DB_USER="${DATABASE_USER:-solace_user}"
DB_NAME="${DATABASE_NAME:-solace_treasury}"
DB_PASS="${DATABASE_PASSWORD:?Set DATABASE_PASSWORD}"
DB_URL="postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}:5432/${DB_NAME}"
set_env() {
local file="$1" key="$2" value="$3"
if grep -q "^${key}=" "$file" 2>/dev/null; then
sed -i "s|^${key}=.*|${key}=${value}|" "$file"
else
echo "${key}=${value}" >> "$file"
fi
}
[[ -f "$ROOT/contracts/deployments/chain138.json" ]] && "$ROOT/scripts/sync-env-from-deployment.sh"
for f in "$ROOT/backend/.env" "$ROOT/backend/.env.indexer"; do
[[ -f "$f" ]] || continue
set_env "$f" DATABASE_URL "$DB_URL"
set_env "$f" NODE_ENV production
done
# Same-origin API when nginx on CT 3000 proxies /api/ (public NPMplus or LAN HTTPS)
if [[ "${SOLACE_API_SAME_ORIGIN:-1}" == "1" ]]; then
set_env "$ROOT/frontend/.env.production" NEXT_PUBLIC_API_URL ""
else
set_env "$ROOT/frontend/.env.production" NEXT_PUBLIC_API_URL "${SOLACE_PUBLIC_API_URL:-http://192.168.11.61:3001}"
fi
set_env "$ROOT/frontend/.env.production" NEXT_PUBLIC_CHAIN138_RPC_URL "${CHAIN138_PUBLIC_RPC_URL:-https://rpc-http-pub.d-bis.org}"
set_env "$ROOT/frontend/.env.production" NEXT_PUBLIC_CHAIN138_WS_URL ""
set_env "$ROOT/frontend/.env.production" NEXT_PUBLIC_CHAIN138_EXPLORER_URL "${CHAIN138_PUBLIC_EXPLORER_URL:-https://explorer.d-bis.org}"
set_env "$ROOT/frontend/.env.production" NODE_ENV production
for f in "$ROOT/backend/.env" "$ROOT/backend/.env.indexer"; do
[[ -f "$f" ]] || continue
set_env "$f" CLIENT_RPC_URL "${CHAIN138_PUBLIC_RPC_URL:-https://rpc-http-pub.d-bis.org}"
done
echo "Prepared production env (DB host ${DB_HOST}, API same-origin=${SOLACE_API_SAME_ORIGIN:-1}, public RPC=${CHAIN138_PUBLIC_RPC_URL:-https://rpc-http-pub.d-bis.org})"