mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +00:00
scripts: Rename DEFAULT_USER to POSTGRES_USER.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
8a15b9ee87
commit
53879c4673
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
DEFAULT_USER="postgres"
|
POSTGRES_USER="postgres"
|
||||||
if [ "$(uname)" = "OpenBSD" ]; then
|
if [ "$(uname)" = "OpenBSD" ]; then
|
||||||
DEFAULT_USER="_postgresql"
|
POSTGRES_USER="_postgresql"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /
|
cd /
|
||||||
@@ -15,7 +15,7 @@ tables="$(printf "'%s'," "${@//\'/\'\'}")"
|
|||||||
tables="${tables%,}"
|
tables="${tables%,}"
|
||||||
|
|
||||||
if [ "$EUID" -eq 0 ]; then
|
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);
|
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname IN ($tables);
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
set -x
|
set -x
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
DEFAULT_USER="postgres"
|
POSTGRES_USER="postgres"
|
||||||
if [ "$(uname)" = "OpenBSD" ]; then
|
if [ "$(uname)" = "OpenBSD" ]; then
|
||||||
DEFAULT_USER="_postgresql"
|
POSTGRES_USER="_postgresql"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ROOT_POSTGRES=(sudo -i -u "$DEFAULT_USER" psql)
|
ROOT_POSTGRES=(sudo -i -u "$POSTGRES_USER" psql)
|
||||||
DEFAULT_DB=""
|
DEFAULT_DB=""
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
ROOT_POSTGRES=(psql)
|
ROOT_POSTGRES=(psql)
|
||||||
@@ -39,13 +39,13 @@ fi
|
|||||||
|
|
||||||
DBNAME_BASE=${DBNAME}_base
|
DBNAME_BASE=${DBNAME}_base
|
||||||
|
|
||||||
if ! pg_isready -U "$DEFAULT_USER" -q; then
|
if ! pg_isready -U "$POSTGRES_USER" -q; then
|
||||||
set +x
|
set +x
|
||||||
echo
|
echo
|
||||||
echo 'ERROR: PostgreSQL Server is not running! Ensure the service is enabled.'
|
echo 'ERROR: PostgreSQL Server is not running! Ensure the service is enabled.'
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
echo 'ERROR: Try `sudo service postgresql start`?'
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user