]> git.pld-linux.org Git - packages/pound.git/blame - pound.init
- more %doc
[packages/pound.git] / pound.init
CommitLineData
59f6c21a 1#!/bin/sh
2#
7dbb2b59 3# pound
59f6c21a 4#
5# chkconfig: 345 85 15
6# description: reverse-proxy and load-balancer
7#
8
9# Source function library
10. /etc/rc.d/init.d/functions
11
12# Get network config
13. /etc/sysconfig/network
14
f33820c6
ER
15# List of instances to start.
16POUND_INSTANCES="pound"
17
59f6c21a 18# Get service config
19[ -f /etc/sysconfig/pound ] && . /etc/sysconfig/pound
20
21# Check that networking is up.
22if is_yes "${NETWORKING}"; then
1a0ae1a4 23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
74738d13 24 msg_network_down pound
25 exit 1
26 fi
59f6c21a 27else
74738d13 28 exit 0
59f6c21a 29fi
30
19b8f25f
ER
31# check if the $1 instance is up
32is_up() {
33 local instance="$1"
34 local pidfile=/var/run/pound/$instance.pid
35 [ -f $pidfile ] || return 1
36 local pid=$(cat $pidfile)
37 kill -0 $pid 2>/dev/null
38 return $?
39}
40
50de9853 41start() {
5208430f 42 local ret started=0
19b8f25f
ER
43 # Check if the service is already running?
44 if [ ! -f /var/lock/subsys/pound -o "$single" = 1 ]; then
45 for instance in $POUND_INSTANCES; do
46 is_up $instance && continue
f33820c6 47 msg_starting "Pound ($instance)"
a332b66d 48 daemon /usr/sbin/pound -v -f /etc/pound/$instance.cfg -p /var/run/pound/$instance.pid
19b8f25f 49 ret=$?
5208430f
ER
50 if [ $RETVAL -eq 0 ]; then
51 RETVAL=$ret
52 started=1
53 fi
19b8f25f 54 done
5208430f 55 [ $started = 1 ] && touch /var/lock/subsys/pound
19b8f25f
ER
56
57 if [ -z "$ret" -a "$single" = 1 ]; then
f33820c6
ER
58 msg_already_running "Pound ($instance)"
59 fi
19b8f25f
ER
60 else
61 msg_already_running "Pound"
62 fi
50de9853
ER
63}
64
65stop() {
19b8f25f 66 local ret
74738d13 67 # Stop daemons.
19b8f25f
ER
68 if [ -f /var/lock/subsys/pound ]; then
69 for instance in $POUND_INSTANCES; do
70 is_up $instance || continue
f33820c6 71 msg_stopping "Pound ($instance)"
19b8f25f
ER
72 killproc --pidfile pound/$instance.pid pound
73 ret=$?
74 done
75 [ "$single" != 1 ] && rm -f /var/lock/subsys/pound > /dev/null 2>&1
76 if [ -z "$ret" -a "$single" = 1 ]; then
f33820c6
ER
77 msg_not_running "Pound ($instance)"
78 fi
19b8f25f
ER
79 else
80 msg_not_running "Pound"
81 fi
50de9853
ER
82}
83
194b939d
ER
84restart() {
85 if [ "$single" != 1 ]; then
86 # make up list of configured and up instances
87 local list
88 for instance in $POUND_INSTANCES; do
89 is_up $instance || continue
90 list="$list $instance"
91 done
92 POUND_INSTANCES=$list
93 fi
94
95 stop
96 start
97}
98
19b8f25f
ER
99if [ "$1" != status -a "$2" ]; then
100 POUND_INSTANCES="$2"
101 single=1
102fi
103
50de9853
ER
104RETVAL=0
105# See how we were called.
106case "$1" in
107 start)
108 start
109 ;;
110 stop)
111 stop
59f6c21a 112 ;;
113 status)
19b8f25f
ER
114 nls "Configured Pound instances:"
115 echo " $POUND_INSTANCES"
116 nls "Currently active Pound instances:"
117 stat=1
118 for pidfile in /var/run/pound/*.pid; do
119 [ -f "$pidfile" ] || continue
120 instance=${pidfile#/var/run/pound/}
121 instance=${instance%.pid}
122 is_up $instance && echo -n " $instance($(cat $pidfile))"
123 stat=0
124 done
125 echo ""
126 exit $stat
59f6c21a 127 ;;
5917fcaf 128 restart|force-reload)
194b939d 129 restart
59f6c21a 130 ;;
131 *)
19b8f25f 132 msg_usage "$0 {start|stop|restart|force-reload|status} [INSTANCE NAMES]"
5917fcaf 133 exit 3
59f6c21a 134esac
135
136exit $RETVAL
This page took 0.389593 seconds and 4 git commands to generate.