root/trunk/tools/autocommit_pg_conf.ksh

Revision 160, 2.6 kB (checked in by ssteinpreis, 4 years ago)

tid 12167 Initial checkin

  • Property svn:executable set to *
Line 
1 #!/bin/ksh
2
3 ##############################################################################
4 # Script to commit postgres conf files into svn
5 # This assumes that the path for svn to use exists under /export/home/postgres
6
7 # Example for crontab:
8 # 2,7,12,17,22,27,32,37,42,47,52,57 * * * * /export/home/postgres/bin/autocommit_pg_conf.ksh -u asautocommit -d /data/set/allisports/84/pgdata
9 ##############################################################################
10
11 #############################################################################
12 #       Process command line options
13 #############################################################################
14
15 USAGE="Usage: ${0##*/} [-u username for svn checkin] [-d fully qualified path to pg conf files]
16
17 -u      username for svn to use for check in
18 -d      fully qualified path for the postgres conf files
19 "
20 while getopts u:d: optc
21 do
22         case $optc in
23                 u)      CI_USER=$OPTARG ;;
24                 d)      PG_CONF_DIR=$OPTARG ;;
25                 *)      echo "$USAGE" >&2
26                         exit 1
27                         ;;
28         esac
29 done
30 shift `expr $OPTIND - 1`
31
32 if [ -z "$CI_USER" ]
33 then
34         echo "\nUsername for svn checkin is required.\n" >&2
35         echo "$USAGE" >&2
36         exit 1
37 fi
38
39 if [ -z "$PG_CONF_DIR" ]
40 then
41         echo "\nDirectory location for pg conf files is required.\n" >&2
42         echo "$USAGE" >&2
43         exit 1
44 fi
45
46 if [ ! -d "$PG_CONF_DIR" ]
47 then
48         echo "\nDirectory location for pg conf files is not a directory.\n" >&2
49         echo "$USAGE" >&2
50         exit 1
51 fi
52
53 if [ ! -f "$PG_CONF_DIR/postgresql.conf" ]
54 then
55         echo "\nThere is no postgresql.conf in $PG_CONF_DIR - supply valid path.\n" >&2
56         echo "$USAGE" >&2
57         exit 1
58 fi
59
60 export PATH='/opt/pgsql/bin:/usr/gnu/bin:/opt/omni/bin:/opt/OMNIperl/bin:/opt/pgsql/bin:/usr/openwin/bin:/usr/perl5/5.8.4/bin:/usr/X11/bin:/usr/dt/bin:/usr/sfw/bin:/usr/ccs/bin:/usr/xpg4/bin:/usr/jdk/instances/jdk1.5.0/jre/bin:/usr/jdk/instances/jdk1.5.0/bin:/usr/xpg6/bin:/usr/bin:/usr/proc/bin:/usr/SUNWale/bin:/usr/sadm/sysadm/bin:/usr/sadm/bin:/usr/sadm/install/bin:/opt/nagios/bin'
61
62 SVN_LOCAL_DIR="/export/home/postgres/svn/$PG_CONF_DIR/"
63
64 if [[ ! -d "$SVN_LOCAL_DIR" ]]
65 then
66     echo "SVN checkout path for $PG_CONF_DIR does not exist ($SVN_LOCAL_DIR)" >&2
67     exit 1
68 fi
69
70 cp "$PG_CONF_DIR"/*.conf "$SVN_LOCAL_DIR"
71
72 cd "$SVN_LOCAL_DIR"
73
74 svn add *.conf > /dev/null 2>&1
75
76 DIFF="$( svn diff 2>&1 )"
77 if [[ -z "$DIFF" ]]
78 then
79     exit 0
80 fi
81
82 COMMIT="$( svn ci --username $CI_USER -m "Autocommit of change" 2>&1 )"
83
84 echo "# svn diff
85 $DIFF
86
87 $COMMIT" | mailx -s "PostgreSQL config change on $( uname -n ) in $PG_CONF_DIR" dba@omniti.com
Note: See TracBrowser for help on using the browser.