#! /bin/sh

PG_VERSION='13'

exec 2>&1
if !( /usr/pgsql-${PG_VERSION}/bin/postgresql-${PG_VERSION}-check-db-dir /var/lib/pgsql/${PG_VERSION}/data > /dev/null )
then
 PGSETUP_INITDB_OPTIONS="--pwfile='/var/lib/pgsql/.pg_pwd'" \
    /usr/pgsql-${PG_VERSION}/bin/postgresql-${PG_VERSION}-setup initdb
    /sbin/e-smith/expand-template /etc/e-smith/pgsql/init/00_restore_backup
#else
# ??   /bin/pgsql -U postgres < /var/lib/pgsql/set.password
fi
