]> git.pld-linux.org Git - packages/lighttpd.git/blame - lighttpd.init
- release 2
[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
dd1d7d33 71 env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
29afef3d 72 RETVAL=$?
dd1d7d33
ER
73 if [ $RETVAL -eq 0 ]; then
74 ok
75 touch /var/lock/subsys/lighttpd
76 else
77 fail
78 fi
29afef3d
ER
79}
80
81stop() {
5be0ba14
ER
82 # Stop daemons.
83 if [ ! -f /var/lock/subsys/lighttpd ]; then
84 msg_not_running "Lighttpd Web Server"
85 return
86 fi
87
88 msg_stopping "Lighttpd Web Server"
29afef3d
ER
89 killproc --pidfile /var/run/lighttpd.pid lighttpd
90 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
91}
92
5be0ba14
ER
93restart() {
94 local pid
95
96 # short circuit to safe reload if pid exists and is alive
97 if [ -f /var/lock/subsys/lighttpd ] && pid=$(pidofproc lighttpd lighttpd.pid) && checkpid $pid; then
98 reload
99 return
100 fi
101
102 checkconfig
103 stop
104 start
105}
106
29afef3d 107reload() {
5be0ba14
ER
108 if [ ! -f /var/lock/subsys/lighttpd ]; then
109 msg_not_running "Lighttpd Web Server"
110 RETVAL=7
111 return
112 fi
113
114 checkconfig
115 msg_reloading "Lighttpd Web Server"
116
29afef3d
ER
117 # sending INT signal will make lighttpd close all listening sockets and
118 # wait for client connections to terminate.
119 killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
120 env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
5be0ba14
ER
121 RETVAL=$?
122}
123
124condrestart() {
125 if [ ! -f /var/lock/subsys/lighttpd ]; then
126 msg_not_running "Lighttpd Web Server"
127 RETVAL=$1
128 return
129 fi
130
131 checkconfig
132 stop
133 start
134}
135
136flush-logs() {
137 if [ ! -f /var/lock/subsys/lighttpd ]; then
138 msg_not_running "Lighttpd Web Server"
139 RETVAL=7
140 return
141 fi
142
143 show "Rotating %s logs" lighttpd
144 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
145 RETVAL=$?
29afef3d
ER
146}
147
cb1656fe
AM
148RETVAL=0
149# See how we were called.
150case "$1" in
151 start)
5be0ba14 152 start
cb1656fe
AM
153 ;;
154 stop)
5be0ba14 155 stop
cb1656fe 156 ;;
29afef3d 157 restart)
5be0ba14 158 restart
cb1656fe 159 ;;
5be0ba14
ER
160 try-restart)
161 condrestart 0
29afef3d 162 ;;
5be0ba14
ER
163 reload|force-reload|graceful)
164 reload
404d7754 165 ;;
29afef3d 166 flush-logs)
5be0ba14
ER
167 flush-logs
168 ;;
169 checkconfig|configtest)
170 checkconfig 1
171 ;;
172 status)
173 status lighttpd
174 RETVAL=$?
cb1656fe
AM
175 ;;
176 *)
404d7754 177 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|status}"
cb1656fe
AM
178 exit 3
179 ;;
180esac
181
182exit $RETVAL
This page took 0.048644 seconds and 4 git commands to generate.