#!/usr/bin/with-contenv bashio # shellcheck shell=bash set -euo pipefail if bashio::config.true 'USE_EXTERNAL_DB'; then # External DB; nothing to create here. exit 0 fi DB_USER="$(bashio::config 'DB_USERNAME')" DB_PASS="$(bashio::config 'DB_PASSWORD')" DB_NAME="$(bashio::config 'DB_DATABASE_NAME')" bashio::log.info "Postgres-init: waiting for local Postgres..." until pg_isready -q -h 127.0.0.1 -p 5432 -U postgres; do sleep 1 done bashio::log.info "Postgres-init: creating role/database if missing..." # psql search_path safe quoting using dollar-quoted strings for password psql -v ON_ERROR_STOP=1 -h 127.0.0.1 -p 5432 -U postgres <