Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
create-database: Hide harmless "non-existant database" warnings.
Alex Vandivera1151aef8b39
diff --git a/scripts/setup/create-database b/scripts/setup/create-databaseindex 0c7245f31d4..b2e6fb96884 100755--- a/scripts/setup/create-database+++ b/scripts/setup/create-database@@ -14,20 +14,18 @@ POSTGRES_USER="${POSTGRES_USER:-postgres}"DATABASE_NAME=$(crudini --get /etc/zulip/zulip.conf postgresql database_name 2>/dev/null || echo zulip)DATABASE_USER=$(crudini --get /etc/zulip/zulip.conf postgresql database_user 2>/dev/null || echo zulip)-# This psql command may fail because the Zulip database doesn’t exist,-# hence the &&.-if records="$(- cd / # Make sure the current working directory is readable by postgres- su "$POSTGRES_USER" -c "psql -v ON_ERROR_STOP=1 -Atc 'SELECT COUNT(*) FROM $DATABASE_NAME.zerver_message;' $DATABASE_USER"-)" && [ "$records" -gt 200 ]; then- set +x- echo "WARNING: This will delete your Zulip database which currently contains $records messages."- read -p "Do you want to proceed? [y/N] " -r- echo- if [[ ! $REPLY =~ ^[Yy]$ ]]; then- exit 1+if [ "$(su "$POSTGRES_USER" -c "cd / && psql -v ON_ERROR_STOP=1 -Atc \"SELECT 1 FROM pg_database WHERE datname='$DATABASE_NAME';\"")" = "1" ]; then+ records="$(su "$POSTGRES_USER" -c "cd / && psql -v ON_ERROR_STOP=1 -Atc 'SELECT COUNT(*) FROM $DATABASE_NAME.zerver_message;' $DATABASE_USER")"+ if [ "$records" -gt 200 ]; then+ set +x+ echo "WARNING: This will delete your Zulip database which currently contains $records messages."+ read -p "Do you want to proceed? [y/N] " -r+ echo+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then+ exit 1+ fi+ set -xfi- set -xfi# Shut down all services to ensure a quiescent state.