Browse code

Merge "Postgres: fix detection of existing roles"

Jenkins authored on 2016/12/21 20:22:15
Showing 1 changed files
... ...
@@ -47,7 +47,7 @@ function recreate_database_postgresql {
47 47
 }
48 48
 
49 49
 function configure_database_postgresql {
50
-    local pg_conf pg_dir pg_hba root_roles version
50
+    local pg_conf pg_dir pg_hba check_role version
51 51
     echo_summary "Configuring and starting PostgreSQL"
52 52
     if is_fedora; then
53 53
         pg_hba=/var/lib/pgsql/data/pg_hba.conf
... ...
@@ -85,8 +85,8 @@ function configure_database_postgresql {
85 85
     restart_service postgresql
86 86
 
87 87
     # Create the role if it's not here or else alter it.
88
-    root_roles=$(sudo -u root sudo -u postgres -i psql -t -c "SELECT 'HERE' from pg_roles where rolname='root'")
89
-    if [[ ${root_roles} == *HERE ]];then
88
+    check_role=$(sudo -u root sudo -u postgres -i psql -t -c "SELECT 'HERE' from pg_roles where rolname='$DATABASE_USER'")
89
+    if [[ ${check_role} == *HERE ]];then
90 90
         sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
91 91
     else
92 92
         sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"