terminate-psql-sessions: Allow running without sudo.

This commit is contained in:
Rohitt Vashishtha 2019-03-17 15:34:42 +05:30 committed by Tim Abbott
parent 042893a448
commit 327b70cb19
1 changed files with 1 additions and 1 deletions

View File

@ -15,7 +15,7 @@ tables="$(printf "'%s'," "${@//\'/\'\'}")"
tables="${tables%,}"
if [ "$EUID" -eq 0 ]; then
sudo -u "$DEFAULT_USER" psql postgres "$DEFAULT_USER" <<EOF
su - "$DEFAULT_USER" -c "psql postgres '$DEFAULT_USER'" <<EOF
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname IN ($tables);
EOF
else