blob: fe31f1b036f57da9b643a2f947f26ced539eca37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: 1a4fa561e16b480a269e548bd1f839ae09efd50b $
extra_started_commands="reload graceful"
LIGHTTPD_PID="$(awk '/^server.pid-file/{s=$3};{sub("\"","",s)};END{print s}' ${LIGHTTPD_CONF} 2>/dev/null)"
LIGHTTPD_PID="${LIGHTTPD_PID:-/var/run/lighttpd.pid}"
depend() {
need net
use mysql logger spawn-fcgi ldap slapd netmount dns
after famd
after sshd
}
checkconfig() {
if [ ! -f "${LIGHTTPD_CONF}" ] ; then
ewarn "${LIGHTTPD_CONF} does not exist."
return 1
fi
LIGHTTPD_PID="$(awk '/^server.pid-file/{s=$3};{sub("\"","",s)};END{print s}' ${LIGHTTPD_CONF} 2>/dev/null)"
if [ -z "${LIGHTTPD_PID:-}" ] ; then
LIGHTTPD_PID="/var/run/lighttpd.pid"
ewarn "server.pid-file variable in ${LIGHTTPD_CONF}"
ewarn "is not set. Falling back to '${LIGHTTPD_PID}'"
fi
/usr/sbin/lighttpd -t -f ${LIGHTTPD_CONF} >/dev/null
}
start() {
checkconfig || return 1
# Glean lighttpd's credentials from the configuration file
# Fixes bug 454366
LIGHTTPD_USER="$(awk '/^server.username/{s=$3};{sub("\"","",s)};END{print s}' ${LIGHTTPD_CONF} 2>/dev/null)"
LIGHTTPD_GROUP="$(awk '/^server.groupname/{s=$3};{sub("\"","",s)};END{print s}' ${LIGHTTPD_CONF} 2>/dev/null)"
checkpath -q -d -m 0750 -o "${LIGHTTPD_USER:-lighttpd}":"${LIGHTTPD_GROUP:-lighttpd}" /var/run/lighttpd/
ebegin "Starting lighttpd"
start-stop-daemon --start --quiet --exec /usr/sbin/lighttpd \
--pidfile "${LIGHTTPD_PID}" -- -f "${LIGHTTPD_CONF}"
eend $?
}
stop() {
local rv=0
ebegin "Stopping lighttpd"
start-stop-daemon --stop --quiet --pidfile "${LIGHTTPD_PID}"
eend $?
}
reload() {
if ! service_started "${SVCNAME}" ; then
eerror "${SVCNAME} isn't running"
return 1
fi
checkconfig || return 1
ebegin "Re-opening lighttpd log files"
start-stop-daemon --quiet --pidfile "${LIGHTTPD_PID}" \
--signal HUP
eend $?
}
graceful() {
if ! service_started "${SVCNAME}" ; then
eerror "${SVCNAME} isn't running"
return 1
fi
checkconfig || return 1
ebegin "Gracefully stopping lighttpd"
start-stop-daemon --quiet --pidfile "${LIGHTTPD_PID}" \
--signal INT
if eend $? ; then
rm -f "${LIGHTTPD_PID}"
start
fi
}
|