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 # Check that networking is up.
20 if is_yes "${NETWORKING}"; then
21 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
22 msg_network_down "Lighttpd Web Server"
30 env SHELL=/bin/sh lighttpd -t -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
33 # wrapper for configtest
37 if [ $details = 1 ]; then
38 # run config test and display report (status action)
39 show "Checking %s configuration" "Lighttpd Web Server"; busy
43 if [ $RETVAL = 0 ]; then
48 [ "$out" ] && echo >&2 "$out"
50 # run config test and abort with nice message if failed
51 # (for actions checking status before action).
52 configtest >/dev/null 2>&1
54 if [ $RETVAL != 0 ]; then
55 show "Checking %s configuration" "Lighttpd Web Server"; fail
56 nls 'Configuration test failed. See details with %s "checkconfig"' $0
63 # Check if the service is already running?
64 if [ -f /var/lock/subsys/lighttpd ]; then
65 msg_already_running "Lighttpd Web Server"
70 msg_starting "Lighttpd Web Server"; busy
71 if is_yes "${LIGHT_ANGEL}"; then
72 daemon --fork --pidfile /var/run/lighttpd-angel.pid --makepid \
73 env SHELL=/bin/sh lighttpd-angel -D -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS 1>&2
76 env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
79 if [ $RETVAL -eq 0 ]; then
81 touch /var/lock/subsys/lighttpd
89 if [ ! -f /var/lock/subsys/lighttpd ]; then
90 msg_not_running "Lighttpd Web Server"
94 msg_stopping "Lighttpd Web Server"
95 killproc --pidfile /var/run/lighttpd.pid lighttpd
96 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
97 rm -f /var/run/lighttpd*.pid >/dev/null 2>&1
103 # short circuit to safe reload if pid exists and is alive
104 if is_yes "${LIGHT_ANGEL}"; then
105 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd-angel lighttpd-angel.pid) && checkpid $pid; then
110 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then
122 # TODO: check if process is running. Start it in this case.
123 if [ ! -f /var/lock/subsys/lighttpd ]; then
124 msg_not_running "Lighttpd Web Server"
130 msg_reloading "Lighttpd Web Server"
132 if is_yes "${LIGHT_ANGEL}"; then
133 # sending HUP signal to angel will make lighttpd close all listening
134 # sockets and wait for client connections to terminate. After that new
135 # child will be started
136 killproc lighttpd-angel -HUP
138 # sending INT signal will make lighttpd close all listening sockets and
139 # wait for client connections to terminate.
140 killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
141 env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
147 if [ ! -f /var/lock/subsys/lighttpd ]; then
148 msg_not_running "Lighttpd Web Server"
159 if [ ! -f /var/lock/subsys/lighttpd ]; then
160 msg_not_running "Lighttpd Web Server"
165 show "Rotating %s logs" lighttpd
166 # send HUP to main lighttpd (not angel) process to rotate logs:
167 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
172 # See how we were called.
186 reload|force-reload|graceful)
192 checkconfig|configtest)
196 status lighttpd-angel
201 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|status}"