mirror of https://github.com/zulip/zulip.git
terminate-psql-sessions: Fix shell and SQL quoting.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
parent
c0792808e2
commit
981f09d950
|
@ -11,10 +11,11 @@ cd /
|
||||||
username=$1
|
username=$1
|
||||||
|
|
||||||
shift
|
shift
|
||||||
tables=$(echo "'$*'" | sed "s/ /','/g")
|
tables="$(printf "'%s'," "${@//\'/\'\'}")"
|
||||||
|
tables="${tables%,}"
|
||||||
|
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [ "$EUID" -eq 0 ]; then
|
||||||
sudo -u "$DEFAULT_USER" sh -c "psql postgres '$DEFAULT_USER'" <<EOF
|
sudo -u "$DEFAULT_USER" psql postgres "$DEFAULT_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
|
||||||
|
|
Loading…
Reference in New Issue