File: cherokee.init

package info (click to toggle)
cherokee 0.7.2-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,808 kB
  • ctags: 6,577
  • sloc: ansic: 45,071; python: 9,628; sh: 9,468; makefile: 1,639; xml: 61; perl: 32
file content (108 lines) | stat: -rw-r--r-- 2,352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /bin/sh
#
# start/stop Cherokee web server

### BEGIN INIT INFO
# Provides:          cherokee
# Required-Start:    $network
# Required-Stop:     $network
# Should-Start:      $named
# Should-Stop:       $named
# Default-Start:     S 2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the Cherokee Web server
# Description:       Start the Cherokee Web server
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/cherokee-guardian
NAME=cherokee

. /lib/lsb/init-functions

set -e

test -x $DAEMON || exit 0

PIDFILE=/var/run/cherokee-guardian.pid


case "$1" in
  start)	
	echo -n "Starting web server: $NAME "
	start-stop-daemon --start --oknodo --pidfile $PIDFILE --exec $DAEMON -b
	;;

  stop)
	echo -n "Stopping web server: $NAME "
	start-stop-daemon --stop --oknodo --pidfile $PIDFILE --exec $DAEMON
	rm -f $PIDFILE
	;;

  restart)
	$0 stop
	sleep 1
	$0 start
	;;

  reload|force-reload)
	echo -n "Reloading web server: $NAME"
	if [ -f $PIDFILE ]
	    then
	    PID=$(cat $PIDFILE)
	    if ps p $PID | grep $NAME >/dev/null 2>&1
	    then
		kill -HUP $PID
	    else
		echo "PID present, but $NAME not found at PID $PID - Cannot reload"
		exit 1
	    fi
	else
	    echo "No PID file present for $NAME - Cannot reload"
	    exit 1
	fi
	;;

  status)
	# Strictly, LSB mandates us to return indicating the different statuses,
	# but that's not exactly Debian compatible - For further information:
	# http://www.freestandards.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/iniscrptact.html
	# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208010
	# ...So we just inform to the invoker and return success.
	echo -n "$NAME web server status: "
	if [ -e $PIDFILE ] ; then
	    PROCNAME=$(ps -p $(cat $PIDFILE) -o comm=)
	    if [ "x$PROCNAME" = "x" ]; then
		echo -n "Not running, but PID file present"
	    else
		if [ "$PROCNAME" = "$NAME" ]; then
		    echo -n "Running"
		else
		    echo -n "PID file points to process '$PROCNAME', not '$NAME'"
		fi
	    fi
	else
	    if PID=$(pidofproc cherokee); then
		echo -n "Running (PID $PID), but PIDFILE not present"
	    else
		echo -n "Not running"
	    fi
	fi
	;;

  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
	exit 1
	;;
esac

if [ $? = 0 ]; then
        echo .
        exit 0
else
        echo failed
        exit 1
fi

exit 0