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 # check for deprecated config options that cause bad side effects
37 # TODO: should remove the deprecated options in pld after some time being warned out
39 out=$(env SHELL=/bin/sh $DAEMON -f $CONFIGFILE $HTTPD_OPTS -p 2>&1 | grep -oE '(url.rewrite|url.rewrite-final)[[:space:]]')
40 if [ -n "$out" ]; then
41 # make it unique, format nicely
42 out=$(echo "$out" | sort -u | xargs | sed -e 's/ /, /g')
43 echo >&2 "WARNING: found deprecated '$out', convert to 'url.rewrite-final' recommented, See http://redmine.lighttpd.net/issues/2379"
46 env SHELL=/bin/sh $DAEMON -t -f $CONFIGFILE $HTTPD_OPTS
49 # wrapper for configtest
53 if [ $details = 1 ]; then
54 # run config test and display report (status action)
55 show "Checking %s configuration" "Lighttpd Web Server"; busy
57 out=$(configtest 2>&1)
59 if [ $RETVAL = 0 ]; then
64 [ "$out" ] && echo >&2 "$out"
66 # run config test and abort with nice message if failed
67 # (for actions checking status before action).
68 configtest >/dev/null 2>&1
70 if [ $RETVAL != 0 ]; then
71 show "Checking %s configuration" "Lighttpd Web Server"; fail
72 nls 'Configuration test failed. See details with %s "checkconfig"' $0
79 # Check if the service is already running?
80 if [ -f /var/lock/subsys/lighttpd ]; then
81 msg_already_running "Lighttpd Web Server"
86 msg_starting "Lighttpd Web Server"; busy
87 if is_yes "${LIGHT_ANGEL}"; then
88 daemon --fork --pidfile /var/run/lighttpd-angel.pid --makepid \
89 env SHELL=/bin/sh $ANGEL_DAEMON -D -f $CONFIGFILE $HTTPD_OPTS
92 env SHELL=/bin/sh $DAEMON -f $CONFIGFILE $HTTPD_OPTS
95 if [ $RETVAL -eq 0 ]; then
97 touch /var/lock/subsys/lighttpd
105 if [ ! -f /var/lock/subsys/lighttpd ]; then
106 msg_not_running "Lighttpd Web Server"
110 msg_stopping "Lighttpd Web Server"
111 killproc --pidfile /var/run/lighttpd.pid lighttpd
112 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
113 rm -f /var/run/lighttpd*.pid >/dev/null 2>&1
119 # short circuit to safe reload if pid exists and is alive
120 if is_yes "${LIGHT_ANGEL}"; then
121 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd-angel lighttpd-angel.pid) && checkpid $pid; then
126 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then
138 # TODO: check if process is running. Start it in this case.
139 if [ ! -f /var/lock/subsys/lighttpd ]; then
140 msg_not_running "Lighttpd Web Server"
146 msg_reloading "Lighttpd Web Server"
148 if is_yes "${LIGHT_ANGEL}"; then
149 # sending HUP signal to angel will make lighttpd close all listening
150 # sockets and wait for client connections to terminate. After that new
151 # child will be started
152 killproc lighttpd-angel -HUP
154 # sending INT signal will make lighttpd close all listening sockets and
155 # wait for client connections to terminate.
156 killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
157 env SHELL=/bin/sh lighttpd -f $CONFIGFILE $HTTPD_OPTS
163 if [ ! -f /var/lock/subsys/lighttpd ]; then
164 msg_not_running "Lighttpd Web Server"
175 if [ ! -f /var/lock/subsys/lighttpd ]; then
176 msg_not_running "Lighttpd Web Server"
181 show "Rotating %s logs" lighttpd
182 # send HUP to main lighttpd (not angel) process to rotate logs:
183 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
188 # See how we were called.
202 reload|force-reload|graceful)
208 checkconfig|configtest)
212 env SHELL=/bin/sh $DAEMON -p -f $CONFIGFILE $HTTPD_OPTS
215 if is_yes "${LIGHT_ANGEL}"; then
216 status lighttpd-angel || RETVAL=$?
218 status lighttpd || RETVAL=$?
221 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|show-config|status}"