echo"File $PG_HBA_CONF.orig exists, refusing to proceed."
exit 1
fi
# Initialize db if needed
dbAction=restart
createDbRootUser=false
if[!-f$PG_HBA_CONF];then
$PG_CONTROL_SCRIPT initdb ||exit 1
dbAction=start
createDbRootUser=true
fi
# Modify db permissions, restart db.
echo"Modifying db access permissions"
mv$PG_HBA_CONF$PG_HBA_CONF.orig
cat$PG_HBA_CONF.orig | sed's?host.*all.*all.*127.*?host all all 127.0.0.1/32 trust?g' | sed's?host.*all.*all.*::1/128.*?host all all ::1/128 trust?g'>$PG_HBA_CONF||exit 1
echo"Restarting database server"
$PG_CONTROL_SCRIPT$dbAction
# Create db root user if needed
sttyOrig=`stty-g`
if[$createDbRootUser="true"];then
# Read db password if needed
if[-z"$DM_DB_ADMIN_PASSWORD"];then
stty-echo
read-p"Enter DB password for the $DM_DB_ADMIN_USER (DB root) user: " DM_DB_ADMIN_PASSWORD
cat$PG_HBA_CONF.orig | sed's?host.*all.*all.*127.*?host all all 127.0.0.1/32 md5?g' | sed's?host.*all.*all.*::1/128.*?host all all ::1/128 md5?g'>$PG_HBA_CONF||exit 1