mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-16 17:38:17 +01:00
20 lines
631 B
Plaintext
Executable File
20 lines
631 B
Plaintext
Executable File
#!/usr/bin/with-contenv bashio
|
|
set -euo pipefail
|
|
|
|
if bashio::config.true 'USE_EXTERNAL_DB'; then
|
|
bashio::log.info "External DB requested; not starting internal Postgres service."
|
|
exit 0
|
|
fi
|
|
|
|
export PGDATA=/data/postgres
|
|
mkdir -p "$PGDATA"
|
|
chown -R postgres:postgres /data
|
|
|
|
if [[ ! -s "$PGDATA/PG_VERSION" ]]; then
|
|
bashio::log.info "Initializing Postgres 17 data directory."
|
|
su - postgres -c "/usr/lib/postgresql/17/bin/initdb -D $PGDATA"
|
|
fi
|
|
|
|
bashio::log.info "Starting Postgres 17 (listening on 127.0.0.1:5432)."
|
|
exec su - postgres -c "/usr/lib/postgresql/17/bin/postgres -D $PGDATA -c listen_addresses='127.0.0.1'"
|