Merge "Postgres: fix detection of existing roles"
This commit is contained in:
commit
72af0d1cab
@ -47,7 +47,7 @@ function recreate_database_postgresql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function configure_database_postgresql {
|
function configure_database_postgresql {
|
||||||
local pg_conf pg_dir pg_hba root_roles version
|
local pg_conf pg_dir pg_hba check_role version
|
||||||
echo_summary "Configuring and starting PostgreSQL"
|
echo_summary "Configuring and starting PostgreSQL"
|
||||||
if is_fedora; then
|
if is_fedora; then
|
||||||
pg_hba=/var/lib/pgsql/data/pg_hba.conf
|
pg_hba=/var/lib/pgsql/data/pg_hba.conf
|
||||||
@ -85,8 +85,8 @@ function configure_database_postgresql {
|
|||||||
restart_service postgresql
|
restart_service postgresql
|
||||||
|
|
||||||
# Create the role if it's not here or else alter it.
|
# Create the role if it's not here or else alter it.
|
||||||
root_roles=$(sudo -u root sudo -u postgres -i psql -t -c "SELECT 'HERE' from pg_roles where rolname='root'")
|
check_role=$(sudo -u root sudo -u postgres -i psql -t -c "SELECT 'HERE' from pg_roles where rolname='$DATABASE_USER'")
|
||||||
if [[ ${root_roles} == *HERE ]];then
|
if [[ ${check_role} == *HERE ]];then
|
||||||
sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
||||||
else
|
else
|
||||||
sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
||||||
|
Loading…
Reference in New Issue
Block a user