smeserver-phppgadmin/root/etc/e-smith/events/actions/smeserver-phpPgAdmin-conf

13 lines
568 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/bash
psql='/usr/pgsql-13/bin/psql'
password=`/sbin/e-smith/db configuration getprop phppgadmin Password || echo "changeme"`
admin=`sudo -Hiu postgres $psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='admin'"`
if [[ $admin -ne '1' ]];then
# sudo -Hiu postgres $psql -c "CREATE USER admin CREATEDB CREATEUSER CREATEROLE ENCRYPTED PASSWORD '$password';"
sudo -Hiu postgres $psql -c "CREATE USER admin CREATEDB CREATEROLE ENCRYPTED PASSWORD '$password';"
else
sudo -Hiu postgres $psql -c "ALTER USER admin WITH PASSWORD '$password';"
exit 0
fi