PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/debian/perlbal.init

http://github.com/perlbal/Perlbal
Shell | 97 lines | 54 code | 14 blank | 29 comment | 4 complexity | 77967738fff133b36c75f65a56632375 MD5 | raw file
 1#! /bin/sh
 2#
 3# perlbal       Start and Stop the perlbal daemon
 4#
 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
14
15# PATH should only include /usr/* if it runs after the mountnfs.sh script
16PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17DAEMON=/usr/sbin/perlbal
18NAME=perlbal
19DESC=Perlbal
20PIDFILE=/var/run/$NAME.pid
21USER=root
22SCRIPTNAME=/etc/init.d/$NAME
23
24# Exit if the package is not installed
25[ -x "$DAEMON" ] || exit 0
26
27set -e
28
29# Read configuration variable file if it is present
30[ -r /etc/default/$NAME ] && . /etc/default/$NAME
31
32# Load the VERBOSE setting and other rcS variables
33. /lib/init/vars.sh
34
35#
36# Function that starts the daemon/service
37#
38do_start()
39{
40	if [ -e $PIDFILE ]
41		then
42		
43		if [ -d /proc/`cat $PIDFILE`/ ]
44		then
45
46			echo "$NAME already running."
47			exit 0;
48		else
49			rm -f $PIDFILE
50		fi
51
52	fi
53
54	start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE -b -m --name $NAME --user $USER
55}
56
57#
58# Function that stops the daemon/service
59#
60do_stop()
61{
62	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name $NAME --user $USER
63	rm -f $PIDFILE
64}
65
66case "$1" in
67  start)
68	echo -n "Starting $DESC: "
69	do_start
70	echo "$NAME."
71	;;
72  stop)
73	echo -n "Stopping $DESC: "
74	do_stop
75	echo "$NAME."
76	;;
77
78  restart|force-reload)
79	#
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".
83	#
84	echo -n "Restarting $DESC: "
85	do_stop
86	sleep 1
87	do_start
88	echo "$NAME."
89	;;
90  *)
91	#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
92	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
93	exit 3
94	;;
95esac
96
97exit 0