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
14 . /etc/sysconfig/network
17 [ -f /etc/sysconfig/lighttpd ] && . /etc/sysconfig/lighttpd
19 DAEMON=/usr/sbin/lighttpd
20 ANGEL_DAEMON=/usr/sbin/lighttpd-angel
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 # check for deprecated config options that cause bad side effects
35 # TODO: should remove the deprecated options in pld after some time being warned out
37 out=$(env SHELL=/bin/sh $DAEMON -f $CONFIGFILE $HTTPD_OPTS -p 2>&1 | grep -oE '(url.rewrite|url.rewrite-final)[[:space:]]')
38 if [ -n "$out" ]; then
39 # make it unique, format nicely
40 out=$(echo "$out" | sort -u | xargs | sed -e 's/ /, /g')
41 echo >&2 "WARNING: found deprecated '$out', convert to 'url.rewrite-final' recommented, See http://redmine.lighttpd.net/issues/2379"
44 env SHELL=/bin/sh $DAEMON -t -f $CONFIGFILE $HTTPD_OPTS
47 # wrapper for configtest
51 if [ $details = 1 ]; then
52 # run config test and display report (status action)
53 show "Checking %s configuration" "Lighttpd Web Server"; busy
55 out=$(configtest 2>&1)
57 if [ $RETVAL = 0 ]; then
62 [ "$out" ] && echo >&2 "$out"
64 # run config test and abort with nice message if failed
65 # (for actions checking status before action).
66 configtest >/dev/null 2>&1
68 if [ $RETVAL != 0 ]; then
69 show "Checking %s configuration" "Lighttpd Web Server"; fail
70 nls 'Configuration test failed. See details with %s "checkconfig"' $0
77 # Check if the service is already running?
78 if [ -f /var/lock/subsys/lighttpd ]; then
79 msg_already_running "Lighttpd Web Server"
84 msg_starting "Lighttpd Web Server"; busy
85 if is_yes "${LIGHT_ANGEL}"; then
86 daemon --fork --pidfile /var/run/lighttpd-angel.pid --makepid \
87 env SHELL=/bin/sh $ANGEL_DAEMON -D -f $CONFIGFILE $HTTPD_OPTS
90 env SHELL=/bin/sh $DAEMON -f $CONFIGFILE $HTTPD_OPTS
93 if [ $RETVAL -eq 0 ]; then
95 touch /var/lock/subsys/lighttpd
103 if [ ! -f /var/lock/subsys/lighttpd ]; then
104 msg_not_running "Lighttpd Web Server"
108 msg_stopping "Lighttpd Web Server"
109 killproc --pidfile /var/run/lighttpd.pid lighttpd
110 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
111 rm -f /var/run/lighttpd*.pid >/dev/null 2>&1
117 # short circuit to safe reload if pid exists and is alive
118 if is_yes "${LIGHT_ANGEL}"; then
119 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd-angel lighttpd-angel.pid) && checkpid $pid; then
124 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then
136 # TODO: check if process is running. Start it in this case.
137 if [ ! -f /var/lock/subsys/lighttpd ]; then
138 msg_not_running "Lighttpd Web Server"
144 msg_reloading "Lighttpd Web Server"
146 if is_yes "${LIGHT_ANGEL}"; then
147 # sending HUP signal to angel will make lighttpd close all listening
148 # sockets and wait for client connections to terminate. After that new
149 # child will be started
150 killproc lighttpd-angel -HUP
152 # sending INT signal will make lighttpd close all listening sockets and
153 # wait for client connections to terminate.
154 killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
155 env SHELL=/bin/sh lighttpd -f $CONFIGFILE $HTTPD_OPTS
161 if [ ! -f /var/lock/subsys/lighttpd ]; then
162 msg_not_running "Lighttpd Web Server"
173 if [ ! -f /var/lock/subsys/lighttpd ]; then
174 msg_not_running "Lighttpd Web Server"
179 show "Rotating %s logs" lighttpd
180 # send HUP to main lighttpd (not angel) process to rotate logs:
181 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
186 # See how we were called.
200 reload|force-reload|graceful)
206 checkconfig|configtest)
210 env SHELL=/bin/sh $DAEMON -p -f $CONFIGFILE $HTTPD_OPTS
213 if is_yes "${LIGHT_ANGEL}"; then
214 status lighttpd-angel || RETVAL=$?
216 status lighttpd || RETVAL=$?
219 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|show-config|status}"