fi
# test DB login
-if ! echo "\q" | psql kivitendo_auth kivitendo
+if ! su postgres -c "psql -c '\du'" | grep kivitendo >/dev/null
then
- # create kivitendo user
+ echo "No user named 'kivitendo' found. It is now created. Use the same password!"
su postgres -c "createuser -dPs kivitendo"
fi
-if ! grep kivitendo /etc/postgresql/*/main/pg_hba.conf >/dev/null
+main=$(ls -d /etc/postgresql/*/main/)
+if ! grep kivitendo $main/pg_hba.conf >/dev/null
then
- echo "local all kivitendo md5" >> /etc/postgresql/*/main/pg_hba.conf
+ echo "local all kivitendo md5" >> $main/pg_hba.conf
systemctl reload postgresql
fi