]> git.pld-linux.org Git - packages/lighttpd.git/blame - lighttpd.init
- load mod_magnet after other path-altering modules (like mod_secdownload), so
[packages/lighttpd.git] / lighttpd.init
CommitLineData
cb1656fe
AM
1#!/bin/sh
2#
3# lighttpd lighttpd Web Server
4#
5# chkconfig: 345 85 15
6# description: lighttpd is a World Wide Web server. It is used to serve \
7# HTML files and CGI.
8#
9
10# Source function library
11. /etc/rc.d/init.d/functions
12
13# Get network config
14. /etc/sysconfig/network
15
16# Get service config
17[ -f /etc/sysconfig/lighttpd ] && . /etc/sysconfig/lighttpd
18
19# Check that networking is up.
20if is_yes "${NETWORKING}"; then
21 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
75526508 22 msg_network_down "Lighttpd Web Server"
cb1656fe
AM
23 exit 1
24 fi
25else
26 exit 0
27fi
28
1ae7ff0d 29configtest() {
5be0ba14
ER
30 env SHELL=/bin/sh lighttpd -t -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
31}
32
33# wrapper for configtest
34checkconfig() {
35 local details=${1:-0}
36
37 if [ $details = 1 ]; then
38 # run config test and display report (status action)
39 show "Checking %s configuration" "Lighttpd Web Server"; busy
40 local out
41 out=`configtest 2>&1`
42 RETVAL=$?
43 if [ $RETVAL = 0 ]; then
44 ok
45 else
46 fail
47 fi
48 [ "$out" ] && echo >&2 "$out"
49 else
50 # run config test and abort with nice message if failed
51 # (for actions checking status before action).
52 configtest >/dev/null 2>&1
53 RETVAL=$?
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
57 exit $RETVAL
58 fi
1ae7ff0d 59 fi
1ae7ff0d
ER
60}
61
29afef3d 62start() {
5be0ba14
ER
63 # Check if the service is already running?
64 if [ -f /var/lock/subsys/lighttpd ]; then
65 msg_already_running "Lighttpd Web Server"
66 return
67 fi
68
69 checkconfig
70 msg_starting "Lighttpd Web Server"; busy
61fdfa32
PG
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
74
75 else
76 env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
77 fi
29afef3d 78 RETVAL=$?
dd1d7d33
ER
79 if [ $RETVAL -eq 0 ]; then
80 ok
6a790b88 81 touch /var/lock/subsys/lighttpd
dd1d7d33
ER
82 else
83 fail
84 fi
29afef3d
ER
85}
86
87stop() {
5be0ba14
ER
88 # Stop daemons.
89 if [ ! -f /var/lock/subsys/lighttpd ]; then
90 msg_not_running "Lighttpd Web Server"
91 return
92 fi
93
94 msg_stopping "Lighttpd Web Server"
29afef3d
ER
95 killproc --pidfile /var/run/lighttpd.pid lighttpd
96 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
61fdfa32 97 rm -f /var/run/lighttpd*.pid >/dev/null 2>&1
29afef3d
ER
98}
99
5be0ba14
ER
100restart() {
101 local pid
102
103 # short circuit to safe reload if pid exists and is alive
61fdfa32
PG
104 if is_yes "${LIGHT_ANGEL}"; then
105 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd-angel lighttpd-angel.pid) && checkpid $pid; then
106 reload
107 return
108 fi
109 else
110 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then
111 reload
112 return
113 fi
5be0ba14
ER
114 fi
115
116 checkconfig
117 stop
118 start
119}
120
29afef3d 121reload() {
61fdfa32 122 # TODO: check if process is running. Start it in this case.
5be0ba14
ER
123 if [ ! -f /var/lock/subsys/lighttpd ]; then
124 msg_not_running "Lighttpd Web Server"
125 RETVAL=7
126 return
127 fi
128
129 checkconfig
130 msg_reloading "Lighttpd Web Server"
131
61fdfa32
PG
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
137 else
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
142 fi
5be0ba14
ER
143 RETVAL=$?
144}
145
146condrestart() {
147 if [ ! -f /var/lock/subsys/lighttpd ]; then
148 msg_not_running "Lighttpd Web Server"
149 RETVAL=$1
150 return
151 fi
152
153 checkconfig
154 stop
155 start
156}
157
158flush-logs() {
159 if [ ! -f /var/lock/subsys/lighttpd ]; then
160 msg_not_running "Lighttpd Web Server"
161 RETVAL=7
162 return
163 fi
164
165 show "Rotating %s logs" lighttpd
61fdfa32 166 # send HUP to main lighttpd (not angel) process to rotate logs:
5be0ba14
ER
167 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
168 RETVAL=$?
29afef3d
ER
169}
170
cb1656fe
AM
171RETVAL=0
172# See how we were called.
173case "$1" in
174 start)
5be0ba14 175 start
cb1656fe
AM
176 ;;
177 stop)
5be0ba14 178 stop
cb1656fe 179 ;;
29afef3d 180 restart)
5be0ba14 181 restart
cb1656fe 182 ;;
5be0ba14
ER
183 try-restart)
184 condrestart 0
29afef3d 185 ;;
5be0ba14
ER
186 reload|force-reload|graceful)
187 reload
404d7754 188 ;;
29afef3d 189 flush-logs)
6a790b88 190 flush-logs
5be0ba14
ER
191 ;;
192 checkconfig|configtest)
193 checkconfig 1
194 ;;
195 status)
d5fc2c4c
ER
196 if is_yes "${LIGHT_ANGEL}"; then
197 status lighttpd-angel || RETVAL=$?
198 fi
199 status lighttpd || RETVAL=$?
cb1656fe
AM
200 ;;
201 *)
404d7754 202 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|status}"
cb1656fe
AM
203 exit 3
204 ;;
205esac
206
207exit $RETVAL
This page took 0.095987 seconds and 4 git commands to generate.