3 # lighttpd lighttpd Web Server
6 # description: lighttpd is a World Wide Web server. It is used to serve \
10 # Source function library
11 . /etc/rc.d/init.d/functions
16 . /etc/sysconfig/network
19 [ -f /etc/sysconfig/lighttpd ] && . /etc/sysconfig/lighttpd
21 DAEMON=/usr/sbin/lighttpd
22 ANGEL_DAEMON=/usr/sbin/lighttpd-angel
23 CONFIGFILE=/etc/lighttpd/lighttpd.conf
25 # Check that networking is up.
26 if is_yes "${NETWORKING}"; then
27 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
28 msg_network_down "Lighttpd Web Server"
36 env SHELL=/bin/sh $DAEMON -t -f $CONFIGFILE $HTTPD_OPTS
39 # wrapper for configtest
43 if [ $details = 1 ]; then
44 # run config test and display report (status action)
45 show "Checking %s configuration" "Lighttpd Web Server"; busy
47 out=$(configtest 2>&1)
49 if [ $RETVAL = 0 ]; then
54 [ "$out" ] && echo >&2 "$out"
56 # run config test and abort with nice message if failed
57 # (for actions checking status before action).
58 configtest >/dev/null 2>&1
60 if [ $RETVAL != 0 ]; then
61 show "Checking %s configuration" "Lighttpd Web Server"; fail
62 nls 'Configuration test failed. See details with %s "checkconfig"' $0
69 # Check if the service is already running?
70 if [ -f /var/lock/subsys/lighttpd ]; then
71 msg_already_running "Lighttpd Web Server"
76 msg_starting "Lighttpd Web Server"; busy
77 if is_yes "${LIGHT_ANGEL}"; then
78 daemon --fork --pidfile /var/run/lighttpd-angel.pid --makepid \
79 env SHELL=/bin/sh $ANGEL_DAEMON -D -f $CONFIGFILE $HTTPD_OPTS
82 env SHELL=/bin/sh $DAEMON -f $CONFIGFILE $HTTPD_OPTS
85 if [ $RETVAL -eq 0 ]; then
87 touch /var/lock/subsys/lighttpd
95 if [ ! -f /var/lock/subsys/lighttpd ]; then
96 msg_not_running "Lighttpd Web Server"
100 msg_stopping "Lighttpd Web Server"
101 killproc --pidfile /var/run/lighttpd.pid lighttpd
102 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
103 rm -f /var/run/lighttpd*.pid >/dev/null 2>&1
109 # short circuit to safe reload if pid exists and is alive
110 if is_yes "${LIGHT_ANGEL}"; then
111 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd-angel lighttpd-angel.pid) && checkpid $pid; then
116 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then
128 # TODO: check if process is running. Start it in this case.
129 if [ ! -f /var/lock/subsys/lighttpd ]; then
130 msg_not_running "Lighttpd Web Server"
136 msg_reloading "Lighttpd Web Server"
138 if is_yes "${LIGHT_ANGEL}"; then
139 # sending HUP signal to angel will make lighttpd close all listening
140 # sockets and wait for client connections to terminate. After that new
141 # child will be started
142 killproc lighttpd-angel -HUP
144 # sending INT signal will make lighttpd close all listening sockets and
145 # wait for client connections to terminate.
146 killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
147 env SHELL=/bin/sh lighttpd -f $CONFIGFILE $HTTPD_OPTS
153 if [ ! -f /var/lock/subsys/lighttpd ]; then
154 msg_not_running "Lighttpd Web Server"
165 if [ ! -f /var/lock/subsys/lighttpd ]; then
166 msg_not_running "Lighttpd Web Server"
171 show "Rotating %s logs" lighttpd
172 # send HUP to main lighttpd (not angel) process to rotate logs:
173 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
178 # See how we were called.
192 reload|force-reload|graceful)
198 checkconfig|configtest)
202 env SHELL=/bin/sh $DAEMON -p -f $CONFIGFILE $HTTPD_OPTS
205 if is_yes "${LIGHT_ANGEL}"; then
206 status lighttpd-angel || RETVAL=$?
208 status lighttpd || RETVAL=$?
211 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|show-config|status}"