104 lines
2.4 KiB
Bash
104 lines
2.4 KiB
Bash
#! /bin/sh
|
|
# Copyright (c) 1995-2004 SUSE LINUX AG, Germany.
|
|
#
|
|
# Author: joe@suse.de, template by ro@suse.de
|
|
# using parts from Torsten.Goedicke@wlw.de
|
|
#
|
|
# /etc/init.d/pen
|
|
# and its symbolic link
|
|
# /usr/sbin/rcpen
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: pen
|
|
# Required-Start: $time $named $syslog $remote_fs
|
|
# Required-Stop: $time $named $syslog $remote_fs
|
|
# Default-Start: 3 5
|
|
# Default-Stop: 0 1 2 4 6
|
|
# Short-Description: Load balancer for tcp based protocols
|
|
# Description: A simple load balancer for tcp based protocols
|
|
### END INIT INFO
|
|
|
|
. /etc/rc.status
|
|
|
|
JOBNAME="$0"
|
|
NAME=pen
|
|
DAEMON=/usr/bin/run$NAME.sh
|
|
CF=/etc/$NAME.cfg
|
|
|
|
PIDDIR="/var/run"
|
|
PIDALL="$PIDDIR/run$NAME.pid"
|
|
|
|
test -r $CF || { echo "$CF not found";
|
|
if [ "$1" = "stop" ]; then exit 0;
|
|
else exit 6; fi; }
|
|
|
|
. $CF
|
|
|
|
# Determine the base and follow a runlevel link name.
|
|
base=${0##*/}
|
|
link=${base#*[SK][0-9][0-9]}
|
|
|
|
# Force execution if not called by a runlevel directory.
|
|
test -x $DAEMON || exit 0
|
|
|
|
rc_reset
|
|
case "$1" in
|
|
start)
|
|
PID=`$PS | grep $NAME | grep -v grep | grep -v $JOBNAME`
|
|
if [ -n "$PID" ]; then
|
|
echo "$NAME load balancer is already running as"
|
|
echo "$PID"
|
|
else
|
|
echo -n "Starting pen load balancer instances"
|
|
for i in $COUNT
|
|
do
|
|
eval PIDFILE=\$PID${i}
|
|
eval OPTIONS=\$PEN${i}
|
|
CFFILE=`echo $PIDFILE | sed 's/pid/conf/'`
|
|
echo $OPTIONS > $CFFILE
|
|
$DAEMON $CFFILE &
|
|
echo $! >> $PIDALL
|
|
done
|
|
fi
|
|
rc_status -v
|
|
;;
|
|
stop)
|
|
echo -n "Shutting down pen load balancer instances"
|
|
test -f $PIDALL && kill -TERM `cat $PIDALL` 2> /dev/null
|
|
test -f $PIDALL && kill -KILL `cat $PIDALL` 2> /dev/null
|
|
rm -f $PIDALL
|
|
for i in $COUNT
|
|
do
|
|
eval PIDFILE=\$PID${i}
|
|
eval OPTIONS=\$PEN${i}
|
|
CFFILE=`echo $PIDFILE | sed 's/pid/conf/'`
|
|
test -f $PIDFILE && kill -TERM `cat $PIDFILE` 2> /dev/null
|
|
rm -f $PIDFILE $CFFILE
|
|
done
|
|
rc_status -v
|
|
;;
|
|
restart)
|
|
echo -n "Restarting pen load balancer instances"
|
|
for i in $COUNT
|
|
do
|
|
eval PIDFILE=\$PID${i}
|
|
eval OPTIONS=\$PEN${i}
|
|
CFFILE=`echo $PIDFILE | sed 's/pid/conf/'`
|
|
echo $OPTIONS > $CFFILE
|
|
kill -TERM `cat $PIDFILE`
|
|
done
|
|
rc_status -v
|
|
;;
|
|
reload)
|
|
echo "Reload pen load balancer instances"
|
|
/sbin/killproc -HUP $DAEMON
|
|
touch $PIDFILE
|
|
rc_status -v
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
rc_exit
|