Skip to content

Commit

Permalink
Support show-guc mode in pgconf.sh.
Browse files Browse the repository at this point in the history
  • Loading branch information
MasaoFujii committed Mar 8, 2012
1 parent 49eeb6c commit 2afabd5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pgcommon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ show_guc ()
GUCNAME="$1"
CONFPATH="$2"

grep -E ^$GUCNAME\ \|\#$GUCNAME\ $CONFPATH | awk 'NR==1 {v=$3} NR!=1 && $1!~"#" {v=$3} END {print v}'
grep -E ^$GUCNAME\ \|\#$GUCNAME\ $CONFPATH | \
awk 'NR==1 {n=$1; v=$3} NR!=1 && $1!~"#" {n=$1; v=$3} END { if (n!="") print n " = " v}'
}

find_all_pgdata ()
Expand Down
19 changes: 16 additions & 3 deletions pgconf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
. pgcommon.sh

CONFFILE="postgresql.conf"
SHOWGUCS=

usage ()
{
Expand All @@ -12,9 +13,10 @@ usage ()
echo " $PROGNAME [OPTIONS] [PGDATA]"
echo ""
echo "Options:"
echo " -p postgresql.conf (default)"
echo " -h pg_hba.conf"
echo " -r recovery.conf"
echo " -p opens postgresql.conf (default)"
echo " -h opens pg_hba.conf"
echo " -r opens recovery.conf"
echo " -s NAME[,...] shows values of specified parameters"
}

while [ $# -gt 0 ]; do
Expand All @@ -28,6 +30,9 @@ while [ $# -gt 0 ]; do
CONFFILE="pg_hba.conf";;
-r)
CONFFILE="recovery.conf";;
-s)
SHOWGUCS="$2 $SHOWGUCS"
shift;;
-*)
elog "invalid option: $1";;
*)
Expand All @@ -39,4 +44,12 @@ done
here_is_installation
pgdata_exists

if [ ! -z "$SHOWGUCS" ]; then
CONFFILE="postgresql.conf"
for gucname in $(echo "$SHOWGUCS" | sed s/','/' '/g); do
show_guc "$gucname" $PGDATA/$CONFFILE
done
exit 0
fi

emacs $PGDATA/$CONFFILE &

0 comments on commit 2afabd5

Please sign in to comment.