1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pagure_ynh.git synced 2024-09-03 19:56:19 +02:00

Add postgresql 9.6 support for debian 9

This commit is contained in:
Jean-Baptiste Holcroft 2017-11-23 16:11:17 +01:00
parent a24e32d59a
commit a59e768f5a

View file

@ -6,17 +6,28 @@ ynh_psql_test_if_first_run() {
echo "PostgreSQL is already installed, no need to create master password" echo "PostgreSQL is already installed, no need to create master password"
else else
pgsql=$(ynh_string_random) pgsql=$(ynh_string_random)
pg_hba=""
echo "$pgsql" >> /etc/yunohost/psql 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 systemctl start postgresql
su --command="psql -c\"ALTER user postgres WITH PASSWORD '${pgsql}'\"" postgres su --command="psql -c\"ALTER user postgres WITH PASSWORD '${pgsql}'\"" postgres
# we can't use peer since YunoHost create users with nologin # we can't use peer since YunoHost create users with nologin
sed -i '/local\s*all\s*all\s*peer/i \ 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 enable postgresql
systemctl reload postgresql systemctl reload postgresql
fi fi
} }
# Open a connection as a user # Open a connection as a user
# #
# example: ynh_psql_connect_as 'user' 'pass' <<< "UPDATE ...;" # example: ynh_psql_connect_as 'user' 'pass' <<< "UPDATE ...;"