|
...
|
...
|
@@ -20,14 +20,21 @@ function recreate_database_postgresql {
|
|
20
|
20
|
|
|
21
|
21
|
function configure_database_postgresql {
|
|
22
|
22
|
echo_summary "Configuring and starting PostgreSQL"
|
|
23
|
|
- if is_fedora || is_suse; then
|
|
|
23
|
+ if is_fedora; then
|
|
24
|
24
|
PG_HBA=/var/lib/pgsql/data/pg_hba.conf
|
|
25
|
25
|
PG_CONF=/var/lib/pgsql/data/postgresql.conf
|
|
26
|
26
|
sudo [ -e $PG_HBA ] || sudo postgresql-setup initdb
|
|
27
|
|
- else
|
|
|
27
|
+ elif is_ubuntu; then
|
|
28
|
28
|
PG_DIR=`find /etc/postgresql -name pg_hba.conf|xargs dirname`
|
|
29
|
29
|
PG_HBA=$PG_DIR/pg_hba.conf
|
|
30
|
30
|
PG_CONF=$PG_DIR/postgresql.conf
|
|
|
31
|
+ elif is_suse; then
|
|
|
32
|
+ PG_HBA=/var/lib/pgsql/data/pg_hba.conf
|
|
|
33
|
+ PG_CONF=/var/lib/pgsql/data/postgresql.conf
|
|
|
34
|
+ # initdb is called when postgresql is first started
|
|
|
35
|
+ sudo [ -e $PG_HBA ] || start_service postgresql
|
|
|
36
|
+ else
|
|
|
37
|
+ exit_distro_not_supported "postgresql configuration"
|
|
31
|
38
|
fi
|
|
32
|
39
|
# Listen on all addresses
|
|
33
|
40
|
sudo sed -i "/listen_addresses/s/.*/listen_addresses = '*'/" $PG_CONF
|
|
...
|
...
|
@@ -35,7 +42,7 @@ function configure_database_postgresql {
|
|
35
|
35
|
sudo sed -i "/^host/s/all\s\+127.0.0.1\/32\s\+ident/$DATABASE_USER\t0.0.0.0\/0\tpassword/" $PG_HBA
|
|
36
|
36
|
# Do password auth for all IPv6 clients
|
|
37
|
37
|
sudo sed -i "/^host/s/all\s\+::1\/128\s\+ident/$DATABASE_USER\t::0\/0\tpassword/" $PG_HBA
|
|
38
|
|
- start_service postgresql
|
|
|
38
|
+ restart_service postgresql
|
|
39
|
39
|
|
|
40
|
40
|
# If creating the role fails, chances are it already existed. Try to alter it.
|
|
41
|
41
|
sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'" || \
|