From 2057057be482a6fe21de3c72ea809939d3d7b201 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Thu, 21 Sep 2023 21:58:11 -0400 Subject: [PATCH] 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. --- scripts/setup/pgroonga-config | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/setup/pgroonga-config b/scripts/setup/pgroonga-config index f2f9dd4112..ee2c71b789 100755 --- a/scripts/setup/pgroonga-config +++ b/scripts/setup/pgroonga-config @@ -4,6 +4,11 @@ set -eux dbversion=$(crudini --get /etc/zulip/zulip.conf postgresql version) 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}" applied_file="$sharedir/pgroonga_setup.sql.applied"