|
...
|
...
|
@@ -64,9 +64,13 @@ function configure_database_postgresql {
|
|
64
|
64
|
sudo sed -i "/^host/s/all\s\+::1\/128\s\+ident/$DATABASE_USER\t::0\/0\tpassword/" $PG_HBA
|
|
65
|
65
|
restart_service postgresql
|
|
66
|
66
|
|
|
67
|
|
- # If creating the role fails, chances are it already existed. Try to alter it.
|
|
68
|
|
- sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'" || \
|
|
69
|
|
- sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
|
|
67
|
+ # Create the role if it's not here or else alter it.
|
|
|
68
|
+ root_roles=$(sudo -u root sudo -u postgres -i psql -t -c "SELECT 'HERE' from pg_roles where rolname='root'")
|
|
|
69
|
+ if [[ ${root_roles} == *HERE ]];then
|
|
|
70
|
+ sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
|
|
71
|
+ else
|
|
|
72
|
+ sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
|
|
73
|
+ fi
|
|
70
|
74
|
}
|
|
71
|
75
|
|
|
72
|
76
|
function install_database_postgresql {
|