]> git.pld-linux.org Git - packages/pgpool-II.git/blob - pgpool.init
- BR: postgresql-devel (thnx LCh)
[packages/pgpool-II.git] / pgpool.init
1 #!/bin/sh
2 #
3 # pgpool        This is the init script for starting up pgpool
4 #
5 # chkconfig:    345 85 15
6 # description:  Pgpool - a connection pooling/replication server for PostgreSQL
7 # processname:  pgpool
8 # pidfile:      /var/run/pgpool.pid
9 # config:       /etc/pgpool.conf
10
11 # Source function library
12 . /etc/rc.d/init.d/functions
13
14 # Get network config
15 . /etc/sysconfig/network
16
17 PGPOOL_BIN=/usr/bin/pgpool
18
19 # Get service config
20 [ -f /etc/sysconfig/pgpool ] && . /etc/sysconfig/pgpool
21
22 # Check that networking is up.
23 if is_yes "${NETWORKING}"; then
24         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
25                 msg_network_down pgpool
26                 exit 1
27         fi
28 else
29         exit 0
30 fi
31
32 if [ ! -f $PGPOOLLOG ]; then
33         touch $PGPOOLLOG
34 fi
35
36
37 start() {
38         # Check if the service is already running?
39         if [ ! -f /var/lock/subsys/pgpool ]; then
40                 msg_starting pgpool
41                 rm -f $PGPOOLPID > /dev/null 2>&1
42                 start-stop-daemon -S -x $PGPOOL_BIN -c $PGPOOLUID:$PGPOOLGID \
43                         -- -f $PGPOOLCONF -a $PGPOOLHBA $OPTS >> $PGPOOLLOG 2>&1
44                 RETVAL=$?
45                 pid_num=`pidof -s $PGPOOL_BIN`  # FIXME: this does not restrict the owner
46                 if [ $pid_num ]; then
47                         echo "Master PID number $pid_num" >> $PGPOOLLOG
48                         echo -n $pid_num > $PGPOOLPID
49                         touch /var/lock/subsys/pgpool
50                         ok
51                 else
52                         RETVAL=1
53                         fail
54                 fi
55                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pgpool
56         else
57                 msg_already_running pgpool
58         fi
59 }
60
61
62 stop() {
63         # Stop daemons.
64         if [ -f /var/lock/subsys/pgpool ]; then
65                 msg_stopping pgpool
66                 busy
67                 $PGPOOL_BIN -f $PGPOOLCONF stop >> $PGPOOLLOG 2>&1
68                 if [ $? -eq 0 ]; then
69                         rm -f /var/lock/subsys/pgpool /var/run/pgpool.pid >/dev/null 2>&1
70                         ok
71                 else
72                         fail
73                 fi
74         else
75                 msg_not_running pgpool
76         fi
77 }
78
79 force-stop() {
80         # Stop daemons (don't wait)
81         if [ -f /var/lock/subsys/pgpool ]; then
82                 msg_stopping pgpool
83                 busy
84                 $PGPOOL_BIN -m fast stop >> $PGPOOLLOG 2>&1
85                 if [ $? -eq 0 ]; then
86                         rm -f /var/lock/subsys/pgpool /var/run/pgpool.pid >/dev/null 2>&1
87                         ok
88                 else
89                         fail
90                 fi
91         else
92                 msg_not_running pgpool
93         fi      
94 }
95
96 RETVAL=0
97 # See how we were called.
98 case "$1" in
99   start)
100         start
101         ;;
102   stop)
103         stop
104         ;;
105   status)
106         status pgpool
107         RETVAL=$?
108         ;;
109   restart)
110         stop
111         start
112         ;;
113   switch)
114         if [ -f /var/lock/subsys/pgpool ]; then
115                 msg_reloading pgpool
116                 pgpool switch >> $PGPOOLLOG 2>&1
117                 RETVAL=$?
118         else
119                 msg_not_running pgpool
120                 RETVAL=7
121         fi
122         ;;
123   force-reload)
124         force-stop
125         start
126         ;;
127   *)
128         msg_usage "$0 {start|stop|restart|force-reload|switch|status}"
129         exit 3
130         ;;
131 esac
132
133 exit $RETVAL
This page took 0.069834 seconds and 3 git commands to generate.