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 CONFIGFILE=/etc/lighttpd/lighttpd.conf
23 # Check that networking is up.
24 if is_yes "${NETWORKING}"; then
25 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
26 msg_network_down "Lighttpd Web Server"
34 env SHELL=/bin/sh lighttpd -t -f $CONFIGFILE $HTTPD_OPTS
37 # wrapper for configtest
41 if [ $details = 1 ]; then
42 # run config test and display report (status action)
43 show "Checking %s configuration" "Lighttpd Web Server"; busy
47 if [ $RETVAL = 0 ]; then
52 [ "$out" ] && echo >&2 "$out"
54 # run config test and abort with nice message if failed
55 # (for actions checking status before action).
56 configtest >/dev/null 2>&1
58 if [ $RETVAL != 0 ]; then
59 show "Checking %s configuration" "Lighttpd Web Server"; fail
60 nls 'Configuration test failed. See details with %s "checkconfig"' $0
67 # Check if the service is already running?
68 if [ -f /var/lock/subsys/lighttpd ]; then
69 msg_already_running "Lighttpd Web Server"
74 msg_starting "Lighttpd Web Server"; busy
75 if is_yes "${LIGHT_ANGEL}"; then
76 daemon --fork --pidfile /var/run/lighttpd-angel.pid --makepid \
77 env SHELL=/bin/sh lighttpd-angel -D -f $CONFIGFILE $HTTPD_OPTS 1>&2
80 env SHELL=/bin/sh lighttpd -f $CONFIGFILE $HTTPD_OPTS
83 if [ $RETVAL -eq 0 ]; then
85 touch /var/lock/subsys/lighttpd
93 if [ ! -f /var/lock/subsys/lighttpd ]; then
94 msg_not_running "Lighttpd Web Server"
98 msg_stopping "Lighttpd Web Server"
99 killproc --pidfile /var/run/lighttpd.pid lighttpd
100 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
101 rm -f /var/run/lighttpd*.pid >/dev/null 2>&1
107 # short circuit to safe reload if pid exists and is alive
108 if is_yes "${LIGHT_ANGEL}"; then
109 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd-angel lighttpd-angel.pid) && checkpid $pid; then
114 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then
126 # TODO: check if process is running. Start it in this case.
127 if [ ! -f /var/lock/subsys/lighttpd ]; then
128 msg_not_running "Lighttpd Web Server"
134 msg_reloading "Lighttpd Web Server"
136 if is_yes "${LIGHT_ANGEL}"; then
137 # sending HUP signal to angel will make lighttpd close all listening
138 # sockets and wait for client connections to terminate. After that new
139 # child will be started
140 killproc lighttpd-angel -HUP
142 # sending INT signal will make lighttpd close all listening sockets and
143 # wait for client connections to terminate.
144 killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
145 env SHELL=/bin/sh lighttpd -f $CONFIGFILE $HTTPD_OPTS
151 if [ ! -f /var/lock/subsys/lighttpd ]; then
152 msg_not_running "Lighttpd Web Server"
163 if [ ! -f /var/lock/subsys/lighttpd ]; then
164 msg_not_running "Lighttpd Web Server"
169 show "Rotating %s logs" lighttpd
170 # send HUP to main lighttpd (not angel) process to rotate logs:
171 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
176 # See how we were called.
190 reload|force-reload|graceful)
196 checkconfig|configtest)
200 env SHELL=/bin/sh lighttpd -p -f $CONFIGFILE $HTTPD_OPTS
203 if is_yes "${LIGHT_ANGEL}"; then
204 status lighttpd-angel || RETVAL=$?
206 status lighttpd || RETVAL=$?
209 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|show-config|status}"