2 # pgpool This is the init script for starting up pgpool-II
5 # description: Starts and stops the pgpool daemon
7 # pidfile: /var/run/pgpool.pid
9 # v1.0.0 Devrim GUNDUZ <devrim@CommandPrompt.com>
10 # - Initial version of Red Hat / Fedora init script
12 # v2.2 Devrim GUNDUZ <devrim@CommandPrompt.com>
13 # - New and improved version which has some fixes.
15 if [ -r /etc/sysconfig/pgpool ]; then
16 . /etc/sysconfig/pgpool
19 # Source function library.
20 INITD=/etc/rc.d/init.d
23 # Get function listing for cross-distribution logic.
24 TYPESET=`typeset -f|grep "declare"`
27 . /etc/sysconfig/network
29 # Check that networking is up.
30 # We need it for pgpool
31 [ "${NETWORKING}" = "no" ] && exit 0
33 # Find the name of the script
35 if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
40 # Set defaults for configuration variables
42 PGPOOLDAEMON=$PGPOOLENGINE/pgpool
43 PGPOOLCONF=/etc/pgpool-II/pgpool.conf
44 PGPOOLPIDDIR=/var/run/pgpool
45 PGPOOLLOG=/var/log/pgpool.log
47 test -x $PGPOOLDAEMON || exit 5
49 # Check whether the config file exists or not
50 if [ ! -r $PGPOOLCONF ]
52 echo "$PGPOOLCONF not found"
58 # Create the log file if it does not exist
59 if [ ! -x $PGPOOLLOG ]
62 chown postgres: $PGPOOLLOG
65 if [ ! -d $PGPOOLPIDDIR ]
68 chown postgres: $PGPOOLPIDDIR
74 pid=`pidof -s "$PGPOOLDAEMON"`
77 echo "pgpool is already running with pid $pid"
78 failure "$PGPOQL_START"
84 PGPOOL_START=$"Starting ${NAME} service: "
86 echo -n "$PGPOOL_START"
88 $PGPOOLDAEMON -f $PGPOOLCONF $OPTS & >> "$PGPOOLLOG" 2>&1 < /dev/null
91 pid=`pidof -s "$PGPOOLDAEMON"`
94 success "$PGPOOL_START"
95 touch /var/lock/subsys/${NAME}
98 failure "$PGPOQL_START"
105 echo -n $"Stopping ${NAME} service: "
106 if [ $UID -ne 0 ]; then
110 killproc /usr/bin/pgpool
111 # $PGPOOLDAEMON stop & >> "$PGPOOLLOG" 2>&1 < /dev/null
113 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${NAME}
120 echo -n $"Sending switchover request to $NAME "
121 $PGPOOLDAEMON -f $PGPOOLCONF switch >> "$PGPOOLLOG" 2>&1 < /dev/null
139 echo -n $"Reloading ${NAME}: "
141 if [ -n "`pidfileofproc $PGPOOLDAEMON`" ] ; then
142 killproc $PGPOOLDAEMON -HUP
144 failure $"Reloading ${NAME}"
151 [ -e /var/lock/subsys/${NAME} ] && restart
155 [ -e /var/lock/subsys/${NAME} ] && stop
158 # See how we were called.
186 echo $"Usage: $0 {start|stop|switch|status|restart|condrestart|condstop|reload|force-reload}"