mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
terminate-psql-sessions: Rely on the caller to set PGHOST, PGUSER.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
f2ce856b8f
commit
fa2496c229
@@ -1,32 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
POSTGRES_USER="postgres"
|
||||
if [ "$(uname)" = "OpenBSD" ]; then
|
||||
POSTGRES_USER="_postgresql"
|
||||
fi
|
||||
|
||||
cd /
|
||||
|
||||
username=$1
|
||||
|
||||
shift
|
||||
tables="$(printf "'%s'," "${@//\'/\'\'}")"
|
||||
tables="${tables%,}"
|
||||
|
||||
case "$(id -un)" in
|
||||
root)
|
||||
psql=(su -s /usr/bin/env - -- "$POSTGRES_USER" psql postgres "$POSTGRES_USER")
|
||||
;;
|
||||
"$POSTGRES_USER")
|
||||
psql=(psql postgres "$POSTGRES_USER")
|
||||
;;
|
||||
*)
|
||||
psql=(psql -h localhost postgres "$username")
|
||||
;;
|
||||
esac
|
||||
|
||||
"${psql[@]}" -v ON_ERROR_STOP=1 <<EOF
|
||||
psql postgres -v ON_ERROR_STOP=1 <<EOF
|
||||
SELECT pg_terminate_backend(s.pid)
|
||||
FROM pg_stat_activity s, pg_roles r
|
||||
WHERE
|
||||
|
||||
Reference in New Issue
Block a user