pgroonga: Do not attempt to configure pgroonga without a database.

This can happen if `machine.pgroonga` is set during initial
installation.  We cannot run `CREATE EXTENSION PGROONGA` because the
database that we need to run that statement in does not exist yet;
make the command a silent no-op that does not create the
`pgroonga_setup.sql.applied` flag file, such that a later
`zulip-puppet-apply` once the database exists can pick up and install
the extension.
This commit is contained in:
Alex Vandiver 2023-09-21 21:58:11 -04:00 committed by Tim Abbott
parent 5308fbdeac
commit 2057057be4
1 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,11 @@ set -eux
dbversion=$(crudini --get /etc/zulip/zulip.conf postgresql version) dbversion=$(crudini --get /etc/zulip/zulip.conf postgresql version)
dbname=$(crudini --get /etc/zulip/zulip.conf postgresql database_name 2>/dev/null || echo zulip) dbname=$(crudini --get /etc/zulip/zulip.conf postgresql database_name 2>/dev/null || echo zulip)
if ! su postgres -c "psql -At -c 'SELECT datname FROM pg_database WHERE NOT datistemplate'" | grep -Fx "$dbname"; then
echo "No database to install into!"
exit 0
fi
sharedir="${1:-/usr/share/postgresql/$dbversion}" sharedir="${1:-/usr/share/postgresql/$dbversion}"
applied_file="$sharedir/pgroonga_setup.sql.applied" applied_file="$sharedir/pgroonga_setup.sql.applied"