]> git.pld-linux.org Git - packages/lighttpd.git/blob - lighttpd.init
- skip configure.in chunk for version bump
[packages/lighttpd.git] / lighttpd.init
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.
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
23                 exit 1
24         fi
25 else
26         exit 0
27 fi
28
29 configtest() {
30         out=`env SHELL=/bin/sh lighttpd -t -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS 2>&1`
31         rc=$?
32         if [ "$rc" = 0 ]; then
33                 return
34         fi
35         echo >&2 ""
36         echo >&2 "$out"
37         fail
38 }
39
40 start() {
41         env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
42         RETVAL=$?
43         if [ $RETVAL -eq 0 ]; then
44                 ok
45                 touch /var/lock/subsys/lighttpd
46         else
47                 fail
48         fi
49         return $RETVAL
50 }
51
52 stop() {
53         killproc --pidfile /var/run/lighttpd.pid lighttpd
54         rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
55 }
56
57 reload() {
58         # sending INT signal will make lighttpd close all listening sockets and
59         # wait for client connections to terminate.
60         killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
61         env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
62 }
63
64 RETVAL=0
65 # See how we were called.
66 case "$1" in
67   start)
68         # Check if the service is already running?
69         if [ ! -f /var/lock/subsys/lighttpd ]; then
70                 msg_starting lighttpd
71                 configtest || exit 1
72                 start
73         else
74                 msg_already_running lighttpd
75         fi
76         ;;
77   stop)
78         # Stop daemons.
79         if [ -f /var/lock/subsys/lighttpd ]; then
80                 msg_stopping lighttpd
81                 stop
82         else
83                 msg_not_running lighttpd
84         fi
85         ;;
86   status)
87         status lighttpd
88         RETVAL=$?
89         ;;
90   restart)
91         if [ -f /var/lock/subsys/lighttpd ]; then
92                 configtest || exit 1
93
94                 # short circuit to safe reload if pid exists and is alive
95                 pid=$(pidofproc lighttpd lighttpd.pid)
96                 if [ "$pid" ] && checkpid $pid; then
97                         msg_reloading lighttpd
98                         reload
99                 else
100                         msg_stopping lighttpd
101                         stop
102                         msg_starting lighttpd
103                         start
104                 fi
105                 RETVAL=$?
106         else
107                 msg_not_running lighttpd
108                 msg_starting lighttpd
109                 start
110         fi
111         ;;
112   reload|graceful|force-reload)
113         if [ -f /var/lock/subsys/lighttpd ]; then
114                 msg_reloading lighttpd
115                 configtest || exit 1
116                 reload
117                 RETVAL=$?
118         else
119                 msg_not_running lighttpd
120                 RETVAL=7
121         fi
122         ;;
123   configtest)
124                 show "Checking lighttpd config syntax"
125                 configtest
126                 RETVAL=$?
127                 [ $RETVAL = 0 ] && ok || fail
128         ;;
129   flush-logs)
130         if [ -f /var/lock/subsys/lighttpd ]; then
131                 nls "Rotating %s logs" lighttpd
132                 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
133                 RETVAL=$?
134         else
135                 msg_not_running lighttpd
136                 RETVAL=7
137         fi
138         ;;
139   *)
140         msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|configtest|flush-logs|status}"
141         exit 3
142         ;;
143 esac
144
145 exit $RETVAL
This page took 0.079916 seconds and 3 git commands to generate.