]> git.pld-linux.org Git - packages/cherokee.git/blame - cherokee.init
rel 4
[packages/cherokee.git] / cherokee.init
CommitLineData
cf957d96
ER
1#!/bin/sh
2#
3# cherokee Start the cherokee HTTP server.
4#
5# chkconfig: 345 20 80
6#
7# description: Cherokee is Fast, Flexible and Lightweight Web server
8#
cf957d96
ER
9
10# Source function library
11. /etc/rc.d/init.d/functions
12
13# Get network config
14. /etc/sysconfig/network
15
16# Get service config - may override defaults
17[ -f /etc/sysconfig/cherokee ] && . /etc/sysconfig/cherokee
18
19# Check that networking is up.
20if is_yes "${NETWORKING}"; then
21 if [ ! -f /var/lock/subsys/network ]; then
1f50c961 22 msg_network_down "Cherokee Web Server"
cf957d96
ER
23 exit 1
24 fi
25else
26 exit 0
27fi
28
2ee27799
ER
29# configtest itself
30# must return non-zero if check failed
31# output is discarded if checkconfig is ran without details
6f4ea149 32configtest() {
2ee27799 33 local test_result="$(/usr/sbin/cherokee -t 2>&1)"
6f4ea149
JK
34 # exit status is not usable here, parse the output
35 if [ "${test_result##Test on*: }" = "OK" ] ; then
36 return 0
37 else
38 echo $test_result >&2
39 return 1
40 fi
41}
42
2ee27799
ER
43# wrapper for configtest
44# with $details = 1 will report ok/fail status to output (status action)
d733f93f 45# with $details = 0 will silently discard ok output, and with fail exit script with failure
2ee27799
ER
46checkconfig() {
47 local details=${1:-0}
48
49 if [ $details = 1 ]; then
50 # run config test and display report (status action)
51 show "Checking %s configuration" "Cherokee Web Server"; busy
52 local out
53 out=$(configtest 2>&1)
cf957d96 54 RETVAL=$?
2ee27799
ER
55 if [ $RETVAL = 0 ]; then
56 ok
57 else
58 fail
1f50c961 59 fi
2ee27799 60 [ "$out" ] && echo >&2 "$out"
cf957d96 61 else
2ee27799
ER
62 # run config test and abort with nice message if failed
63 # (for actions checking status before action).
64 configtest >/dev/null 2>&1
65 RETVAL=$?
66 if [ $RETVAL != 0 ]; then
67 show "Checking %s configuration" "Cherokee Web Server"; fail
68 nls 'Configuration test failed. See details with %s "checkconfig"' $0
69 exit $RETVAL
70 fi
71 fi
72}
73
74start() {
75 # Check if the service is already running?
76 if [ -f /var/lock/subsys/cherokee ]; then
1f50c961 77 msg_already_running "Cherokee Web Server"
2ee27799
ER
78 return
79 fi
80
2ee27799
ER
81 msg_starting "Cherokee Web Server"
82 daemon cherokee -d
83 RETVAL=$?
84 if [ $RETVAL -eq 0 ]; then
85 touch /var/lock/subsys/cherokee
cf957d96 86 fi
9ad9ac92
ER
87}
88
89stop() {
2ee27799 90 if [ ! -f /var/lock/subsys/cherokee ]; then
1f50c961 91 msg_not_running "Cherokee Web Server"
2ee27799 92 return
cf957d96 93 fi
2ee27799
ER
94
95 # Stop daemons.
2ee27799
ER
96 msg_stopping "Cherokee Web Server"
97 killproc cherokee
98 RETVAL=$?
99 rm -f /var/lock/subsys/cherokee >/dev/null 2>&1
9ad9ac92
ER
100}
101
102condrestart() {
2ee27799 103 if [ ! -f /var/lock/subsys/cherokee ]; then
9ad9ac92
ER
104 msg_not_running "Cherokee Web Server"
105 RETVAL=$1
2ee27799 106 return
9ad9ac92 107 fi
2ee27799
ER
108
109 checkconfig
110 stop
111 start
9ad9ac92
ER
112}
113
6f4ea149 114reload() {
2ee27799 115 if [ ! -f /var/lock/subsys/cherokee ]; then
6f4ea149
JK
116 msg_not_running "Cherokee Web Server"
117 RETVAL=7
118 fi
2ee27799
ER
119
120 checkconfig
121 msg_reloading "Cherokee Web Server"
122 pid="$(pidofproc cherokee)"
123 if [ -n "$pid" ] && kill -HUP $(pidofproc cherokee); then
124 ok
125 elif [ "$1" = "force-reload" ] ; then
126 fail
127 stop
128 start
129 RETVAL=$?
130 else
131 fail
132 RETVAL=1
133 fi
6f4ea149
JK
134}
135
9ad9ac92
ER
136RETVAL=0
137# See how we were called.
138case "$1" in
139 start)
2ee27799 140 start
cf957d96 141 ;;
9ad9ac92 142 stop)
2ee27799 143 stop
9ad9ac92
ER
144 ;;
145 restart)
2ee27799
ER
146 checkconfig
147 stop
148 start
6f4ea149
JK
149 ;;
150 reload|force-reload)
2ee27799 151 reload $1
9ad9ac92
ER
152 ;;
153 try-restart)
154 condrestart 0
155 ;;
2ee27799
ER
156 checkconfig|configtest)
157 checkconfig 1
cf957d96
ER
158 RETVAL=$?
159 ;;
2ee27799
ER
160 status)
161 status cherokee
6f4ea149
JK
162 RETVAL=$?
163 ;;
cf957d96 164 *)
2ee27799 165 msg_usage "$0 {start|stop|restart|try-restart|force-reload|configtest|status}"
cf957d96
ER
166 exit 3
167esac
168
169exit $RETVAL
This page took 0.186737 seconds and 4 git commands to generate.