start: create pwfile only if it does not already exist

This commit is contained in:
Sameer Naik
2015-02-04 12:16:35 +05:30
parent f75e33f072
commit 2af478b7cd
+7 -2
View File
@@ -32,11 +32,16 @@ cat >> ${PG_CONFDIR}/pg_hba.conf <<EOF
host all all 0.0.0.0/0 md5
EOF
cd ${PG_HOME}
# initialize PostgreSQL data directory
if [ ! -d ${PG_DATADIR} ]; then
if [ ! -f "${PG_HOME}/pwfile" ]; then
PG_PASSWORD=$(pwgen -c -n -1 14)
echo "${PG_PASSWORD}" > ${PG_HOME}/pwfile
fi
echo "Initializing database..."
PG_PASSWORD=$(pwgen -c -n -1 14)
echo "${PG_PASSWORD}" > ${PG_HOME}/pwfile
sudo -u postgres -H "${PG_BINDIR}/initdb" \
--pgdata="${PG_DATADIR}" --pwfile=${PG_HOME}/pwfile \
--username=postgres --encoding=unicode --auth=trust >/dev/null