aboutsummaryrefslogtreecommitdiffstats
path: root/main/varnish
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
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')
-rw-r--r--main/varnish/APKBUILD23
-rw-r--r--main/varnish/varnish.pre-install2
-rw-r--r--main/varnish/varnishd.confd17
-rw-r--r--[-rwxr-xr-x]main/varnish/varnishd.initd54
4 files changed, 65 insertions, 31 deletions
diff --git a/main/varnish/APKBUILD b/main/varnish/APKBUILD
index e09e4369b5..8e000a3d2a 100644
--- a/main/varnish/APKBUILD
+++ b/main/varnish/APKBUILD
@@ -3,7 +3,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=varnish
pkgver=3.0.4
-pkgrel=0
+pkgrel=1
pkgdesc="High-performance HTTP accelerator"
url="http://www.varnish-cache.org/"
arch="all"
@@ -56,10 +56,11 @@ package() {
|| return 1
install -Dm644 "$srcdir"/varnishd.logrotate \
"$pkgdir"/etc/logrotate.d/varnishd || return 1
- install -d -o varnish -g varnish \
- "$pkgdir"/var/cache/varnish \
- "$pkgdir"/var/log/varnish \
- || return 1
+ install -d -o varnish -g varnish \
+ "$pkgdir"/var/cache/varnish \
+ "$pkgdir"/var/log/varnish \
+ "$pkgdir"/var/lib/varnish \
+ || return 1
find "$pkgdir" -name *.la -print | xargs rm
}
@@ -70,17 +71,17 @@ libs() {
}
md5sums="a130ce9c3504b9603a46542635e18701 varnish-3.0.4.tar.gz
-c2659431b145229c1fb7f885a55d6fc2 varnishd.initd
-459d87260de5ee9ba7ca590d85418620 varnishd.confd
+5aa262fc6da61ded082393fe10dbad2a varnishd.initd
+0482f094e6d8ca59adb5b031d6c56b08 varnishd.confd
a6cb8a43c9465699cf956dc992998225 varnishd.logrotate
8c5532869bea7f668e2ce5d4585359f8 varnish-3.0.3-pthread-uclibc.patch"
sha256sums="4e044ccb5c76222bddf89c808f13ea8f66977972675aecb48a920f6800ad0f79 varnish-3.0.4.tar.gz
-d27bda9b6606ec1776f67888055615a80310291e9211211bac40f399d066e605 varnishd.initd
-9418e5c91584d202015df824096885dbb260959bf53b4ed30bab6e5b237acbd2 varnishd.confd
+8e75973cc20a462988171adab5550a2b9dfa4ec2887312074aaf2a411846f7cd varnishd.initd
+f3bc8ba994085d459b83422101d3966d13212e96aba02df0c9bbb2118819090c varnishd.confd
017173cb42bb60f853063b7fbc843120c547e501233ce2299e1066b5d81e4d5e varnishd.logrotate
3e39323ff4d741a9a0337e84eee7ce9f8b5419722a3b905f09ccf2486a9ff24f varnish-3.0.3-pthread-uclibc.patch"
sha512sums="d6fa8d320050f659f341af20b24c4401609ffd77207a7889b98e5378c507db04eda310e2b953b5144d748a0b3c08884e87d5c36962f0a38f03014708ff7c78d0 varnish-3.0.4.tar.gz
-3496225ac1b94dde5fa3137afd40a0d58074eb95d4291517fbbe87044156e3b3cf2185c546da1347bef669f786cd4576374158448f6a415f9c8ef43f97748942 varnishd.initd
-d229a235091a1905b3e756699a28c1d978b84b8bec8978fdf08a0d68823fbaaa8d438d1ad54cc3f04e01c96c80baa6880c1c84a9bdf5dcb5fb43ace685c10b61 varnishd.confd
+b48897b24e452a6e36fac25ebdd1ac272cb0a7f9c5b6ab895daa77777e8be6f8f4ed7555a06046daa4dc149e85f8129758367bf630cbb0b8c73f98629d8e07a8 varnishd.initd
+ba17b04682fc30ebf736647d248ce4db11dc53434c93344a74c605f516799c5d7ad01a9a358cc707fdf5be17f5e96fd4a91f68641f24f2edb82f40b9675b11a1 varnishd.confd
8fb1cba86ede5eff28a494f6b1da1a651d66383cdeb63922104407f28903dea0c643155b6d7ac8353b8c63d480a6c5b43a70c7252bc51ee73317c33a1844c52c varnishd.logrotate
c06cd005ba04725ec69a9b5cb138fe2487bbd0b0e0aa4c6a39314b6473b160874d0c8452fca466e4efa907a998752e65940288a65a33b88cc4f206f1180b68d8 varnish-3.0.3-pthread-uclibc.patch"
diff --git a/main/varnish/varnish.pre-install b/main/varnish/varnish.pre-install
index 0ce9831c29..930d46b995 100644
--- a/main/varnish/varnish.pre-install
+++ b/main/varnish/varnish.pre-install
@@ -1,5 +1,5 @@
#!/bin/sh
-addgroup varnish 2>/dev/null
+addgroup -S varnish 2>/dev/null
adduser -S -H -h /var/lib/varnish -s /sbin/nologin -D -G varnish varnish 2>/dev/null
exit 0
diff --git a/main/varnish/varnishd.confd b/main/varnish/varnishd.confd
index 1471f82078..4d72cb7f96 100644
--- a/main/varnish/varnishd.confd
+++ b/main/varnish/varnishd.confd
@@ -2,7 +2,7 @@
# Varnish configuration file
-VARNISH_CONF="/etc/varnish/default.vcl"
+# VARNISH_CONF="/etc/varnish/default.vcl"
VARNISH_SECRET_FILE="/etc/varnish/secret"
@@ -10,27 +10,20 @@ VARNISH_SECRET_FILE="/etc/varnish/secret"
VARNISH_LISTEN_ADDRESS=
VARNISH_PORT=8080
-# Varnish work files
-VARNISH_WORKING_DIR="/var/cache/varnish"
+# Varnish storage
VARNISH_STORAGE_FILE="/var/cache/varnish/varnish_storage.bin"
VARNISH_STORAGE_SIZE=50M
VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"
-
-# PID files
-VARNISHD_PID_FILE=/var/run/varnish/varnishd.pid
-VARNISHNCSA_PID_FILE=/var/run/varnish/varnishncsa.pid
+# VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
# Varnish admin
ADMINHOSTPORT="127.0.0.1:65080"
# options passed to varnish on startup
# please see the varnishd man page for more options
-VARNISHD_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_PORT} -f ${VARNISH_CONF} -s ${VARNISH_STORAGE} -n $VARNISH_WORKING_DIR -T $ADMINHOSTPORT"
-
-# add user
-VARNISHD_OPTS="-u varnish $VARNISHD_OPTS"
+VARNISHD_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_PORT} -s ${VARNISH_STORAGE} -T $ADMINHOSTPORT"
# arguments passed to varnishncsa
# please see the varnishncsa man page for more options
-VARNISHNCSA_ARGS="-c -a -w /var/log/varnish/access.log"
+VARNISHNCSA_ARGS="-c -a -w /var/log/varnish/${SVCNAME}.log"
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