Created
December 11, 2014 20:28
-
-
Save sebastianwebber/d3e4ad21d086ebde8a5b to your computer and use it in GitHub Desktop.
Generates pgauth's file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export AUTH_FILE=/etc/pgbouncer/pgbouncer.auth | |
TMPFILE=$( mktemp ) | |
trap 'rm -f "$TMPFILE"' EXIT | |
psql -Upostgres -p 9876 -qAtX -c 'SELECT $$"$$ || replace( usename, $$"$$, $$""$$) || $$" "$$ || replace( passwd, $$"$$, $$""$$ ) || $$"$$ from pg_shadow where passwd is not null order by 1' > "$TMPFILE" | |
if [[ ! -s "$TMPFILE" ]] | |
then | |
exit | |
fi | |
if diff -q "$AUTH_FILE" "$TMPFILE" &>/dev/null | |
then | |
exit | |
fi | |
cat "$TMPFILE" > "$AUTH_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment