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 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24 msg_network_down "Lighttpd Web Server"
32 env SHELL=/bin/sh lighttpd -t -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
35 # wrapper for configtest
39 if [ $details = 1 ]; then
40 # run config test and display report (status action)
41 show "Checking %s configuration" "Lighttpd Web Server"; busy
45 if [ $RETVAL = 0 ]; then
50 [ "$out" ] && echo >&2 "$out"
52 # run config test and abort with nice message if failed
53 # (for actions checking status before action).
54 configtest >/dev/null 2>&1
56 if [ $RETVAL != 0 ]; then
57 show "Checking %s configuration" "Lighttpd Web Server"; fail
58 nls 'Configuration test failed. See details with %s "checkconfig"' $0
65 # Check if the service is already running?
66 if [ -f /var/lock/subsys/lighttpd ]; then
67 msg_already_running "Lighttpd Web Server"
72 msg_starting "Lighttpd Web Server"; busy
73 if is_yes "${LIGHT_ANGEL}"; then
74 daemon --fork --pidfile /var/run/lighttpd-angel.pid --makepid \
75 env SHELL=/bin/sh lighttpd-angel -D -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS 1>&2
78 env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
81 if [ $RETVAL -eq 0 ]; then
83 touch /var/lock/subsys/lighttpd
91 if [ ! -f /var/lock/subsys/lighttpd ]; then
92 msg_not_running "Lighttpd Web Server"
96 msg_stopping "Lighttpd Web Server"
97 killproc --pidfile /var/run/lighttpd.pid lighttpd
98 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
99 rm -f /var/run/lighttpd*.pid >/dev/null 2>&1
105 # short circuit to safe reload if pid exists and is alive
106 if is_yes "${LIGHT_ANGEL}"; then
107 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd-angel lighttpd-angel.pid) && checkpid $pid; then
112 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then
124 # TODO: check if process is running. Start it in this case.
125 if [ ! -f /var/lock/subsys/lighttpd ]; then
126 msg_not_running "Lighttpd Web Server"
132 msg_reloading "Lighttpd Web Server"
134 if is_yes "${LIGHT_ANGEL}"; then
135 # sending HUP signal to angel will make lighttpd close all listening
136 # sockets and wait for client connections to terminate. After that new
137 # child will be started
138 killproc lighttpd-angel -HUP
140 # sending INT signal will make lighttpd close all listening sockets and
141 # wait for client connections to terminate.
142 killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
143 env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
149 if [ ! -f /var/lock/subsys/lighttpd ]; then
150 msg_not_running "Lighttpd Web Server"
161 if [ ! -f /var/lock/subsys/lighttpd ]; then
162 msg_not_running "Lighttpd Web Server"
167 show "Rotating %s logs" lighttpd
168 # send HUP to main lighttpd (not angel) process to rotate logs:
169 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
174 # See how we were called.
188 reload|force-reload|graceful)
194 checkconfig|configtest)
198 env SHELL=/bin/sh lighttpd -p -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
201 if is_yes "${LIGHT_ANGEL}"; then
202 status lighttpd-angel || RETVAL=$?
204 status lighttpd || RETVAL=$?
207 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|show-config|status}"