scripts: Rename DEFAULT_USER to POSTGRES_USER.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-04-12 16:30:49 -07:00 committed by Tim Abbott
parent 8a15b9ee87
commit 53879c4673
2 changed files with 8 additions and 8 deletions

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
set -e
DEFAULT_USER="postgres"
POSTGRES_USER="postgres"
if [ "$(uname)" = "OpenBSD" ]; then
DEFAULT_USER="_postgresql"
POSTGRES_USER="_postgresql"
fi
cd /
@ -15,7 +15,7 @@ tables="$(printf "'%s'," "${@//\'/\'\'}")"
tables="${tables%,}"
if [ "$EUID" -eq 0 ]; then
su - "$DEFAULT_USER" -c "psql postgres '$DEFAULT_USER'" <<EOF
su - "$POSTGRES_USER" -c "psql postgres '$POSTGRES_USER'" <<EOF
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname IN ($tables);
EOF
else

View File

@ -2,12 +2,12 @@
set -x
set -e
DEFAULT_USER="postgres"
POSTGRES_USER="postgres"
if [ "$(uname)" = "OpenBSD" ]; then
DEFAULT_USER="_postgresql"
POSTGRES_USER="_postgresql"
fi
ROOT_POSTGRES=(sudo -i -u "$DEFAULT_USER" psql)
ROOT_POSTGRES=(sudo -i -u "$POSTGRES_USER" psql)
DEFAULT_DB=""
if [ "$(uname)" = "Darwin" ]; then
ROOT_POSTGRES=(psql)
@ -39,13 +39,13 @@ fi
DBNAME_BASE=${DBNAME}_base
if ! pg_isready -U "$DEFAULT_USER" -q; then
if ! pg_isready -U "$POSTGRES_USER" -q; then
set +x
echo
echo 'ERROR: PostgreSQL Server is not running! Ensure the service is enabled.'
# shellcheck disable=SC2016
echo 'ERROR: Try `sudo service postgresql start`?'
echo "ERROR: You can easily test if you fixed it using: pg_isready -U \$DEFAULT_USER"
echo "ERROR: You can easily test if you fixed it using: pg_isready -U \$POSTGRES_USER"
exit 1
fi