Merge pull request #23 from dsteinbrunner/patch-2
[perlbal.git] / debian / perlbal.init
blob1fa223dcf6d2fd113ee480c84cd6280f85c90fb3
1 #! /bin/sh
3 # perlbal Start and Stop the perlbal daemon
5 ### BEGIN INIT INFO
6 # Provides: perlbal
7 # Required-Start: $local_fs $remote_fs $network $syslog
8 # Required-Stop: $local_fs $remote_fs $network $syslog
9 # Default-Start: 2 3 4 5
10 # Default-Stop: 0 1 6
11 # Short-Description: Start/Stop the perlbal daemon
12 # Description: Start/Stop the perlbal daemon.
13 ### END INIT INFO
15 # PATH should only include /usr/* if it runs after the mountnfs.sh script
16 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17 DAEMON=/usr/sbin/perlbal
18 NAME=perlbal
19 DESC=Perlbal
20 PIDFILE=/var/run/$NAME.pid
21 USER=root
22 SCRIPTNAME=/etc/init.d/$NAME
24 # Exit if the package is not installed
25 [ -x "$DAEMON" ] || exit 0
27 set -e
29 # Read configuration variable file if it is present
30 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
32 # Load the VERBOSE setting and other rcS variables
33 . /lib/init/vars.sh
36 # Function that starts the daemon/service
38 do_start()
40 if [ -e $PIDFILE ]
41 then
43 if [ -d /proc/`cat $PIDFILE`/ ]
44 then
46 echo "$NAME already running."
47 exit 0;
48 else
49 rm -f $PIDFILE
54 start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE -b -m --name $NAME --user $USER
58 # Function that stops the daemon/service
60 do_stop()
62 start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name $NAME --user $USER
63 rm -f $PIDFILE
66 case "$1" in
67 start)
68 echo -n "Starting $DESC: "
69 do_start
70 echo "$NAME."
72 stop)
73 echo -n "Stopping $DESC: "
74 do_stop
75 echo "$NAME."
78 restart|force-reload)
80 # If the "reload" option is implemented, move the "force-reload"
81 # option to the "reload" entry above. If not, "force-reload" is
82 # just the same as "restart".
84 echo -n "Restarting $DESC: "
85 do_stop
86 sleep 1
87 do_start
88 echo "$NAME."
91 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
92 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
93 exit 3
95 esac
97 exit 0