]> git.pld-linux.org Git - packages/lighttpd.git/blob - lighttpd.init
- "reload" will just reopen logs, so move "graceful" where "restart" is
[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 RETVAL=0
41 # See how we were called.
42 case "$1" in
43   start)
44         # Check if the service is already running?
45         if [ ! -f /var/lock/subsys/lighttpd ]; then
46                 msg_starting lighttpd
47                 configtest || exit 1
48                 daemon env SHELL=/bin/sh lighttpd -f /etc/lighttpd/lighttpd.conf $HTTPD_OPTS
49                 RETVAL=$?
50                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lighttpd
51         else
52                 msg_already_running lighttpd
53         fi
54         ;;
55   stop)
56         # Stop daemons.
57         if [ -f /var/lock/subsys/lighttpd ]; then
58                 msg_stopping lighttpd
59                 killproc --pidfile /var/run/lighttpd.pid lighttpd
60                 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
61         else
62                 msg_not_running lighttpd
63         fi
64         ;;
65   status)
66         status lighttpd
67         RETVAL=$?
68         ;;
69   restart|graceful)
70         if [ -f /var/lock/subsys/lighttpd ]; then
71                 msg_stopping lighttpd
72                 configtest || exit 1
73                 # sending INT signal will make lighttpd close all listening sockets and
74                 # wait for client connections to terminate.
75                 killproc --pidfile /var/run/lighttpd.pid lighttpd -INT
76                 rm -f /var/lock/subsys/lighttpd >/dev/null 2>&1
77         fi
78         $0 start
79         ;;
80   reload|force-reload)
81         # this is not reload. it will just reopen logs
82         if [ -f /var/lock/subsys/lighttpd ]; then
83                 msg_reloading lighttpd
84                 configtest || exit 1
85                 killproc --pidfile /var/run/lighttpd.pid lighttpd -HUP
86                 RETVAL=$?
87         else
88                 msg_not_running lighttpd
89                 RETVAL=7
90         fi
91         ;;
92   *)
93         msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"
94         exit 3
95         ;;
96 esac
97
98 exit $RETVAL
This page took 0.037554 seconds and 4 git commands to generate.