From a59e768f5aeadb71a624b612343fb98378775803 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Thu, 23 Nov 2017 16:11:17 +0100 Subject: [PATCH] Add postgresql 9.6 support for debian 9 --- scripts/_common.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 4384a8a..f6dfbd9 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,17 +6,28 @@ ynh_psql_test_if_first_run() { echo "PostgreSQL is already installed, no need to create master password" else pgsql=$(ynh_string_random) + pg_hba="" echo "$pgsql" >> /etc/yunohost/psql + + if [ -e /etc/postgresql/9.4/ ] + then + pg_hba=/etc/postgresql/9.4/main/pg_hba.conf + elif [ -e /etc/postgresql/9.6/ ] + then + pg_hba=/etc/postgresql/9.6/main/pg_hba.conf + else + ynh_die "postgresql shoud be 9.4 or 9.6" + fi + systemctl start postgresql su --command="psql -c\"ALTER user postgres WITH PASSWORD '${pgsql}'\"" postgres # we can't use peer since YunoHost create users with nologin sed -i '/local\s*all\s*all\s*peer/i \ - local all all password' /etc/postgresql/9.4/main/pg_hba.conf + local all all password' "$pg_hba" systemctl enable postgresql systemctl reload postgresql fi } - # Open a connection as a user # # example: ynh_psql_connect_as 'user' 'pass' <<< "UPDATE ...;"