pound -c -f /etc/pound/$instance.cfg > /dev/null
}
-
# check if the $1 instance is up
is_up() {
local instance="$1"
# check if all of the instances are up
all_up() {
- local ret=0 instance pidfile
+ local ret=1 instance pidfile
for pidfile in /var/run/pound/*.pid; do
[ -f "$pidfile" ] || continue
instance=${pidfile#/var/run/pound/}
instance=${instance%.pid}
is_up $instance && continue
- ret=1
+ ret=0
done
return $ret
local ret started=0 found=0 instance
# Check if the service is already running?
- if ! all_up; then
- msg_starting "Pound"; started
- for instance in $POUND_INSTANCES; do
- show "Starting Pound instance %s" "$instance"
- if is_up $instance; then
- started
- continue
- fi
-
- PIDFILE=/var/run/pound/$instance.pid
- start-stop-daemon --start \
- --exec /usr/sbin/pound \
- --pidfile $PIDFILE -- -v -f /etc/pound/$instance.cfg -p $PIDFILE
- ret=$?
-
- if [ $ret -eq 0 ]; then
- ok
- RETVAL=$ret
- started=1
- found=1
- else
- fail
- fi
- done
-
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pound
- else
+ if all_up; then
msg_already_running "Pound"
+ return
fi
+
+ msg_starting "Pound"; started
+ for instance in $POUND_INSTANCES; do
+ show "Starting Pound instance %s" "$instance"
+ if is_up $instance; then
+ started
+ continue
+ fi
+
+ PIDFILE=/var/run/pound/$instance.pid
+ start-stop-daemon --start \
+ --exec /usr/sbin/pound \
+ --pidfile $PIDFILE -- -v -f /etc/pound/$instance.cfg -p $PIDFILE
+ ret=$?
+
+ if [ $ret -eq 0 ]; then
+ ok
+ RETVAL=$ret
+ started=1
+ found=1
+ else
+ fail
+ fi
+ done
+
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pound
}
stop() {
- local ret instance
# Stop daemons.
- if any_up; then
- msg_stopping "Pound"; started
- for instance in $POUND_INSTANCES; do
- is_up $instance || continue
- show "Stopping Pound instance %s" "$instance"; busy
- killproc --pidfile pound/$instance.pid pound
- ret=$?
- done
- rm -f /var/lock/subsys/pound > /dev/null 2>&1
- else
+ if ! any_up; then
msg_not_running "Pound"
+ return
fi
+
+ local ret instance
+ msg_stopping "Pound"; started
+ for instance in $POUND_INSTANCES; do
+ is_up $instance || continue
+ show "Stopping Pound instance %s" "$instance"; busy
+ killproc --pidfile pound/$instance.pid pound
+ ret=$?
+ done
+ rm -f /var/lock/subsys/pound > /dev/null 2>&1
+ rm -f /var/run/pound/$instance.pid > /dev/null 2>&1
}
restart() {
local instance
- # make up list of configured and up instances
- local list
- show "Checking configuration"; busy
- for instance in $POUND_INSTANCES; do
- # skip ones whose config fails
- configtest $instance || continue
- list="$list $instance"
- done
- ok
+ if any_up; then
+ # make up list of configured and up instances
+ local list
+ show "Checking configuration"; busy
+ for instance in $POUND_INSTANCES; do
+ # skip ones whose config fails
+ configtest $instance || continue
+ list="$list $instance"
+ done
+
+ # nothing left or never was
+ if [ -z "$list" ]; then
+ fail
+ return
+ else
+ POUND_INSTANCES=$list
+ ok
+ fi
- POUND_INSTANCES=$list
+ fi
stop
start
}
-if [ "$1" != status -a "$2" ]; then
- POUND_INSTANCES="$2"
-fi
+condrestart() {
+ if [ ! -f /var/lock/subsys/pound ]; then
+ msg_not_running "Pound"
+ RETVAL=$1
+ return
+ fi
+
+ stop
+ start
+}
pound_status() {
- local stat pidfile instance
+ local stat=1 pidfile instance
nls "Configured Pound instances:"
echo " $POUND_INSTANCES"
nls "Currently active Pound instances:"
- stat=1
for pidfile in /var/run/pound/*.pid; do
[ -f "$pidfile" ] || continue
instance=${pidfile#/var/run/pound/}
exit $stat
}
+if [ "$1" != status -a "$2" ]; then
+ POUND_INSTANCES="$2"
+fi
+
RETVAL=0
# See how we were called.
case "$1" in
stop)
stop
;;
- status)
- pound_status
- ;;
- restart|force-reload)
+ restart)
restart
;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ condrestart 7
+ ;;
flush-logs)
if [ -f /var/lock/subsys/pound ]; then
for instance in $POUND_INSTANCES; do
RETVAL=7
fi
;;
+ status)
+ pound_status
+ ;;
*)
- msg_usage "$0 {start|stop|restart|force-reload|status} [INSTANCE NAMES]"
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|flush-logs|status} [INSTANCE NAMES]"
exit 3
esac