For discussion of Alpine Linux development and developer support

2 2

[alpine-devel] [PATCH] Improved confd and add checkpath, build fixes

V.Krishn
Details
Message ID
<1368019281-23699-1-git-send-email-vkrishn4@gmail.com>
Sender timestamp
1368019281
DKIM signature
missing
Download raw message
Patch: +57 -13
From: "V.Krishn" <vkrishn4@gmail.com>

---
 main/varnish/APKBUILD            | 16 +++++++++++-----
 main/varnish/varnish.pre-install |  5 +++++
 main/varnish/varnishd.confd      | 28 ++++++++++++++++++++++++++--
 main/varnish/varnishd.initd      | 21 +++++++++++++++------
 4 files changed, 57 insertions(+), 13 deletions(-)
 create mode 100644 main/varnish/varnish.pre-install

diff --git a/main/varnish/APKBUILD b/main/varnish/APKBUILD
index 6fafe20..adb1162 100644
--- a/main/varnish/APKBUILD
+++ b/main/varnish/APKBUILD
@@ -1,8 +1,9 @@
 # Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
+# Contributor: V.Krishn <vkrishn4@gmail.com>
 # Maintainer: Natanael Copa <ncopa@alpinelinux.org>
 pkgname=varnish
 pkgver=3.0.3
-pkgrel=1
+pkgrel=2
 pkgdesc="High-performance HTTP accelerator"
 url="http://www.varnish-cache.org/"
 arch="all"
@@ -10,8 +11,10 @@ license="BSD"
 depends="gcc libc-dev"
 depends_dev=
 makedepends="$depends_dev pcre-dev ncurses-dev"
-install=""
+install="varnish.pre-install"
 subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
+pkgusers="varnish"
+pkggroups="varnish"
 source="http://repo.varnish-cache.org/source/varnish-$pkgver.tar.gz
 	varnishd.initd
 	varnishd.confd
@@ -50,7 +53,10 @@ package() {
 		|| return 1
 	install -Dm644 "$srcdir"/varnishd.logrotate \
 		"$pkgdir"/etc/logrotate.d/varnishd || return 1
-	mkdir -p "$pkgdir"/var/log/varnish
+        install -d -o varnish -g varnish \
+                "$pkgdir"/var/cache/varnish \
+                "$pkgdir"/var/log/varnish \
+                || return 1
 	find "$pkgdir" -name *.la -print | xargs rm
 }
 
@@ -61,7 +67,7 @@ libs() {
 }
 
 md5sums="714310c83fdbd2061d897dacd3f63d8b  varnish-3.0.3.tar.gz
-4f78964bf3eb6f1fd0fd2d533575982e  varnishd.initd
-6dd289ba81464eacc238109143126d6a  varnishd.confd
+c2659431b145229c1fb7f885a55d6fc2  varnishd.initd
+459d87260de5ee9ba7ca590d85418620  varnishd.confd
 a6cb8a43c9465699cf956dc992998225  varnishd.logrotate
 8c5532869bea7f668e2ce5d4585359f8  varnish-3.0.3-pthread-uclibc.patch"
diff --git a/main/varnish/varnish.pre-install b/main/varnish/varnish.pre-install
new file mode 100644
index 0000000..0ce9831
--- /dev/null
+++ b/main/varnish/varnish.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+addgroup 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 1b46706..1471f82 100644
--- a/main/varnish/varnishd.confd
+++ b/main/varnish/varnishd.confd
@@ -1,12 +1,36 @@
 # /etc/conf.d/varnishd
 
+
+# Varnish configuration file
+VARNISH_CONF="/etc/varnish/default.vcl"
+
+VARNISH_SECRET_FILE="/etc/varnish/secret"
+
+# Varnish address
+VARNISH_LISTEN_ADDRESS=
+VARNISH_PORT=8080
+
+# Varnish work files
+VARNISH_WORKING_DIR="/var/cache/varnish"
+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 admin
 ADMINHOSTPORT="127.0.0.1:65080"
-CFG_FILE="/etc/varnish/default.vcl"
 
 # options passed to varnish on startup
 # please see the varnishd man page for more options
-VARNISHD_OPTS="-a 127.0.0.1:8080 -T $ADMINHOSTPORT -f $CFG_FILE"
+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"
 
 # arguments passed to varnishncsa
 # please see the varnishncsa man page for more options
 VARNISHNCSA_ARGS="-c -a -w /var/log/varnish/access.log"
+
diff --git a/main/varnish/varnishd.initd b/main/varnish/varnishd.initd
index b8c5653..54fb4a0 100755
--- a/main/varnish/varnishd.initd
+++ b/main/varnish/varnishd.initd
@@ -3,6 +3,7 @@
 # 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"
 
 depend() {
@@ -11,26 +12,34 @@ depend() {
 
 start() {
 	ebegin "Starting varnish"
+        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 /var/run/varnishd.pid --exec /usr/sbin/varnishd -- -P /var/run/varnishd.pid ${VARNISHD_OPTS} &> /dev/null
+	start-stop-daemon --quiet --start \
+	                  --pidfile ${VARNISHD_PID_FILE} \
+			  --exec /usr/sbin/varnishd \
+			  -- -P ${VARNISHD_PID_FILE} ${VARNISHD_OPTS} &> /dev/null
 	eend $?
 
 	if [ "${VARNISHNCSA_ARGS}" != "" ]; then
 		ebegin "Starting varnish logging"
-		start-stop-daemon --quiet --start --pidfile /var/run/varnishncsa.pid --exec /usr/bin/varnishncsa -- -D -P /var/run/varnishncsa.pid ${VARNISHNCSA_ARGS}
+		start-stop-daemon --quiet --start \
+				--pidfile ${VARNISHNCSA_PID_FILE} \
+				--exec /usr/bin/varnishncsa \
+				-- -D -P ${VARNISHNCSA_PID_FILE} ${VARNISHNCSA_ARGS}
 		eend $?
 	fi
 }
 
 stop() {
 	ebegin "Stopping varnish"
-	start-stop-daemon --quiet --stop --pidfile /var/run/varnishd.pid
+	start-stop-daemon --quiet --stop --pidfile ${VARNISHD_PID_FILE}
 	eend $?
 
-	if [ -e /var/run/varnishncsa.pid ]; then
+	if [ -e ${VARNISHNCSA_PID_FILE} ]; then
 		ebegin "Stopping varnish logging"
-		start-stop-daemon --quiet --stop --pidfile /var/run/varnishncsa.pid
+		start-stop-daemon --quiet --stop --pidfile ${VARNISHNCSA_PID_FILE}
 		eend $?
 	fi
 }
@@ -47,7 +56,7 @@ reload() {
 
 	# reload new one
 	NOW=$(date +%Y%m%d-%H%M%S-%s)
-	/usr/bin/varnishadm -T $ADMINHOSTPORT vcl.load reload-$NOW $CFG_FILE > /dev/null
+	/usr/bin/varnishadm -T $ADMINHOSTPORT vcl.load reload-$NOW ${VARNISH_CONF} > /dev/null
 	/usr/bin/varnishadm -T $ADMINHOSTPORT vcl.use  reload-$NOW > /dev/null
 
 	eend $?
-- 
1.8.0



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Nathan Angelacos
Details
Message ID
<518AE6CF.1020600@nothome.org>
In-Reply-To
<20130508221510.2c8c5148@ncopa-laptop.res.nor.wtbts.net> (view parent)
Sender timestamp
1368057551
DKIM signature
missing
Download raw message
On 05/08/2013 01:15 PM, Natanael Copa wrote:

> I think it looks very good. I'll push it tomorrow unless someone
> objects.
> 

+1 from here.


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Natanael Copa
Details
Message ID
<20130508221510.2c8c5148@ncopa-laptop.res.nor.wtbts.net>
In-Reply-To
<1368019281-23699-1-git-send-email-vkrishn4@gmail.com> (view parent)
Sender timestamp
1368044110
DKIM signature
missing
Download raw message
On Wed,  8 May 2013 13:21:21 +0000
"V.Krishn" <vkrishn4@gmail.com> wrote:

> From: "V.Krishn" <vkrishn4@gmail.com>
> 
> ---
>  main/varnish/APKBUILD            | 16 +++++++++++-----
>  main/varnish/varnish.pre-install |  5 +++++
>  main/varnish/varnishd.confd      | 28 ++++++++++++++++++++++++++--
>  main/varnish/varnishd.initd      | 21 +++++++++++++++------
>  4 files changed, 57 insertions(+), 13 deletions(-)
>  create mode 100644 main/varnish/varnish.pre-install

I think it looks very good. I'll push it tomorrow unless someone
objects.

Thanks!

-nc


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---