aports/main/lighttpd/lighttpd.initd
Natanael Copa bf277d94c5 main/lighttpd: set /var/{run,log}/lighttpd permission on start
Needed when server.user and server.group is not set to default
value and we run from RAM.

fixes #606
2011-05-03 06:54:53 +00:00

75 lines
1.7 KiB
Plaintext

#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/lighttpd.initd-1.4.13-r3,v 1.2 2007/10/12 20:54:46 swegener Exp $
opts="reload graceful"
depend() {
need net
use mysql logger spawn-fcgi ldap slapd
after famd firewall sshd
}
_confopt() {
/usr/sbin/lighttpd -p -f ${LIGHTTPD_CONF} | awk -F = \
"/$1/"' {sub(/^ *"/, "", $2); sub(/" */, "", $2); print $2}'
}
checkconfig() {
if [ ! -f "${LIGHTTPD_CONF}" ] ; then
ewarn "${LIGHTTPD_CONF} does not exist."
return 1
fi
/usr/sbin/lighttpd -t -f ${LIGHTTPD_CONF} >/dev/null
}
start() {
checkconfig || return 1
local _user=$(_confopt server.user)
local _group=$(_confopt server.group)
chown $_user:$_group /var/*/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 --stop --oknodo --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 --stop --oknodo --quiet --pidfile "${LIGHTTPD_PID}" \
--signal INT
if eend $? ; then
rm -f "${LIGHTTPD_PID}"
start
fi
}