1
0
mirror of git://f0xx.org/ac/ac-deploy synced 2026-07-29 04:38:48 +03:00
Files
ac-deploy/sim/cluster0/scripts/deploy-postgres-semi.sh
Anton Afanasyeu 98f30786b7 cluster0: composed ac backend, /issues/ nginx, postgres semi-prod
Compose lab PHP from ac-workspace overlay; 301 /crashes/ → /issues/;
verify on issues path; optional native Postgres on cast01.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 13:10:35 +02:00

33 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Optional semi-prod PostgreSQL on cast01 (native Alpine, no Docker).
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
# shellcheck source=/dev/null
. "$ROOT/scripts/lib/common.sh"
load_cluster_env
[ "$(host_short)" = "$CAST01_HOST" ] || { log "postgres semi-prod: cast01 only — skip on $(host_short)"; exit 0; }
PG_VER="${POSTGRES_SEMI_VERSION:-16}"
DB_NAME="${POSTGRES_SEMI_DB:-androidcast_semi_pg}"
if ! apk info -e "postgresql${PG_VER}" >/dev/null 2>&1; then
log "install postgresql${PG_VER}"
apk add --no-cache "postgresql${PG_VER}" "postgresql${PG_VER}-contrib" || apk add --no-cache postgresql postgresql-contrib
fi
if [ ! -d /var/lib/postgresql/data/PG_VERSION ]; then
log "initdb"
mkdir -p /var/lib/postgresql/data
chown postgres:postgres /var/lib/postgresql/data
su postgres -c "initdb -D /var/lib/postgresql/data"
fi
rc-service postgresql restart 2>/dev/null || rc-service postgresql start
sleep 2
su postgres -c "psql -tc \"SELECT 1 FROM pg_database WHERE datname='${DB_NAME}'\" | grep -q 1" \
|| su postgres -c "createdb ${DB_NAME}"
log "postgres_semi_ok db=${DB_NAME} host=127.0.0.1"