aboutsummaryrefslogtreecommitdiffstats
path: root/main/varnish/varnishd.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-10-30 14:11:51 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-10-30 14:12:52 +0000
commite0ae350c49a81528d3189e94e2286cd7a7d3cfd7 (patch)
treeaa86354199a3124664ff1906628d13effdc1b92a /main/varnish/varnishd.initd
parent6b85d6b99939dec708c3a1a27dd4647aa60c7afa (diff)
downloadaports-e0ae350c49a81528d3189e94e2286cd7a7d3cfd7.tar.bz2
aports-e0ae350c49a81528d3189e94e2286cd7a7d3cfd7.tar.xz
main/varnish: misc fixes in init.d script
http://lists.alpinelinux.org/alpine-devel/3300.html
Diffstat (limited to 'main/varnish/varnishd.initd')
-rw-r--r--[-rwxr-xr-x]main/varnish/varnishd.initd54
1 files changed, 47 insertions, 7 deletions
diff --git a/main/varnish/varnishd.initd b/main/varnish/varnishd.initd
index 54fb4a0a75..2b9dec79bc 100755..100644
--- a/main/varnish/varnishd.initd
+++ b/main/varnish/varnishd.initd
@@ -3,23 +3,57 @@
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/varnish/files/varnishd.initd,v 1.7 2009/08/30 06:28:07 hollow Exp $
-VARNISH_CONF=${VARNISH_CONF:-${CFG_FILE}}
-extra_commands="reload flush"
+extra_commands="configtest"
+extra_started_commands="reload flush"
+command=/usr/sbin/varnishd
+
+instance=${SVCNAME#*.}
+instance_opt="-n $instance"
+if [ "$instance" = "$SVCNAME" ]; then
+ instance=""
+ instance_opt=""
+fi
+
+default_conf="${instance:-default}.vcl"
+: ${VARNISH_CONF:=${CFG_FILE:-"/etc/varnish/$default_conf"}}
+: ${VARNISHD_PID_FILE:="/var/run/varnish/${SVCNAME}.pid"}
+: ${VARNISHNCSA_PID_FILE:="/var/run/varnish/varnishncsa${instance:+.}${instance}.pid"}
+
depend() {
need net
+ after firewall
+}
+
+checkconfig() {
+ if ! $command -C -f ${VARNISH_CONF} >/dev/null 2>&1; then
+ error "$SVCNAME has deteced an error in your setup:"
+ $command -C -f ${VARNISH_CONF}
+ fi
+}
+
+configtest() {
+ ebegin "Checkinf ${SVCNAME} configuration"
+ checkconfig
+ eend $?
}
start() {
- ebegin "Starting varnish"
+ checkconfig || return 1
+ ebegin "Starting ${SVCNAME}"
checkpath --directory --owner varnish:varnish \
--mode 755 ${VARNISHD_PID_FILE%/*}
#allow varnishd to lock logfile to memory
ulimit -l 82000
start-stop-daemon --quiet --start \
--pidfile ${VARNISHD_PID_FILE} \
- --exec /usr/sbin/varnishd \
- -- -P ${VARNISHD_PID_FILE} ${VARNISHD_OPTS} &> /dev/null
+ --exec $command \
+ -- \
+ -f ${VARNISH_CONF} \
+ -P ${VARNISHD_PID_FILE} \
+ -u varnish -g varnish \
+ $instance_opt \
+ ${VARNISHD_OPTS} &> /dev/null
eend $?
if [ "${VARNISHNCSA_ARGS}" != "" ]; then
@@ -27,7 +61,10 @@ start() {
start-stop-daemon --quiet --start \
--pidfile ${VARNISHNCSA_PID_FILE} \
--exec /usr/bin/varnishncsa \
- -- -D -P ${VARNISHNCSA_PID_FILE} ${VARNISHNCSA_ARGS}
+ -- \
+ -D -P ${VARNISHNCSA_PID_FILE} \
+ $instance_opt \
+ ${VARNISHNCSA_ARGS}
eend $?
fi
}
@@ -39,12 +76,15 @@ stop() {
if [ -e ${VARNISHNCSA_PID_FILE} ]; then
ebegin "Stopping varnish logging"
- start-stop-daemon --quiet --stop --pidfile ${VARNISHNCSA_PID_FILE}
+ start-stop-daemon --quiet --stop \
+ --pidfile ${VARNISHNCSA_PID_FILE}
eend $?
fi
}
reload() {
+ checkconfig || return 1
+
ebegin "Reloading varnish"
# purge unused old configurations