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