Merge "Handle more nicely when role root is already here"
This commit is contained in:
commit
68f142324d
@ -64,9 +64,13 @@ function configure_database_postgresql {
|
|||||||
sudo sed -i "/^host/s/all\s\+::1\/128\s\+ident/$DATABASE_USER\t::0\/0\tpassword/" $PG_HBA
|
sudo sed -i "/^host/s/all\s\+::1\/128\s\+ident/$DATABASE_USER\t::0\/0\tpassword/" $PG_HBA
|
||||||
restart_service postgresql
|
restart_service postgresql
|
||||||
|
|
||||||
# If creating the role fails, chances are it already existed. Try to alter it.
|
# Create the role if it's not here or else alter it.
|
||||||
sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'" || \
|
root_roles=$(sudo -u root sudo -u postgres -i psql -t -c "SELECT 'HERE' from pg_roles where rolname='root'")
|
||||||
sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
if [[ ${root_roles} == *HERE ]];then
|
||||||
|
sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
||||||
|
else
|
||||||
|
sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_database_postgresql {
|
function install_database_postgresql {
|
||||||
|
Loading…
Reference in New Issue
Block a user