added DB
This commit is contained in:
1 parent
1e07bf76ba
commit
78253c60f4
2 files changed
+52
-10
No files matched your search
@@ -1216,6 +1216,45 @@ run_build_group() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Ensure a local PostgreSQL DB is available for the DB tools (dbUpdate, dbAdministration, ...).
|
||||
# Checks whether the server is pre-installed (baked into the image); if not, installs
|
||||
# postgresql-18. Then maps EXCDBS01/EXCADB01 -> 127.0.0.1 and starts the cluster, seeding
|
||||
# the roles (postgres, ctc_sv) + databases (lts_ets_pro, dbAdmin) the tools connect with.
|
||||
# Entirely non-fatal: a DB problem must never abort the build.
|
||||
ensure_database() {
|
||||
log_info "Checking for a pre-installed PostgreSQL server..."
|
||||
if ls /usr/lib/postgresql/*/bin/postgres >/dev/null 2>&1; then
|
||||
log_info "PostgreSQL server already installed - skipping apt install"
|
||||
else
|
||||
log_info "PostgreSQL server not found - installing postgresql-18"
|
||||
apt-get update -qq || true
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq postgresql-18 >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
# Map the app's DB hostnames to the local server + start the cluster (idempotent).
|
||||
grep -qE 'EXCDBS01' /etc/hosts || echo '127.0.0.1 EXCDBS01 EXCADB01' >> /etc/hosts
|
||||
pg_ctlcluster 18 main start >/dev/null 2>&1 || true
|
||||
sleep 1
|
||||
|
||||
# Ensure the roles + databases the DB tools use (idempotent; login password is 'postgres').
|
||||
su postgres -c "psql -c \"ALTER USER postgres PASSWORD 'postgres'\"" >/dev/null 2>&1 || true
|
||||
if ! su postgres -c "psql -tAc \"SELECT 1 FROM pg_roles WHERE rolname='ctc_sv'\"" 2>/dev/null | grep -q 1; then
|
||||
su postgres -c "psql -c \"CREATE ROLE ctc_sv LOGIN PASSWORD 'postgres' CREATEDB\"" >/dev/null 2>&1 || true
|
||||
fi
|
||||
if ! su postgres -c "psql -tAc \"SELECT 1 FROM pg_database WHERE datname='lts_ets_pro'\"" 2>/dev/null | grep -q 1; then
|
||||
su postgres -c "createdb -O postgres lts_ets_pro" >/dev/null 2>&1 || true
|
||||
fi
|
||||
if ! su postgres -c "psql -tAc \"SELECT 1 FROM pg_database WHERE datname='dbAdmin'\"" 2>/dev/null | grep -q 1; then
|
||||
su postgres -c "createdb -O postgres dbAdmin" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if pg_isready -h 127.0.0.1 -p 5432 >/dev/null 2>&1; then
|
||||
log_info "PostgreSQL ready on 127.0.0.1:5432 (roles postgres/ctc_sv, dbs lts_ets_pro/dbAdmin)"
|
||||
else
|
||||
log_info "WARNING: PostgreSQL not ready on 127.0.0.1:5432 (DB tools may not connect; install may have failed)"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "${USE_PREBUILT_IMAGE}" == "ON" ]]; then
|
||||
log_info "Using prebuilt Docker image - skipping apt-get install and Qt6 package installation"
|
||||
else
|
||||
@@ -1228,6 +1267,9 @@ else
|
||||
install_qt6_packages
|
||||
fi
|
||||
|
||||
# Ensure the local PostgreSQL DB (dbUpdate / dbAdministration, ...) is available before the build.
|
||||
ensure_database
|
||||
|
||||
export RTI_LICENSE_FILE=/workspace/rti_license.dat
|
||||
export QT_QPA_PLATFORM=offscreen
|
||||
|
||||
|
||||
Reference in new issue
Block a user