summaryrefslogtreecommitdiff
path: root/www-servers/varnish/files
diff options
context:
space:
mode:
Diffstat (limited to 'www-servers/varnish/files')
-rw-r--r--www-servers/varnish/files/varnish-3.0.3-pthread-uclibc.patch35
-rw-r--r--www-servers/varnish/files/varnish-3.0.4-automagic.patch94
-rw-r--r--www-servers/varnish/files/varnish-3.0.4-fix-automake-1.13.patch12
-rw-r--r--www-servers/varnish/files/varnish-3.0.5-fix-python-path.patch9
-rw-r--r--www-servers/varnish/files/varnish-3.0.5-path-to-vmod_vcc.patch12
-rw-r--r--www-servers/varnish/files/varnish-4.0.0-fix-man-Makefile_am.patch14
-rw-r--r--www-servers/varnish/files/varnish-4.0.1-fix-doc-Makefile_am.patch14
-rw-r--r--www-servers/varnish/files/varnish-4.0.1-fix-man-Makefile_am.patch19
-rw-r--r--www-servers/varnish/files/varnish-4.0.1-fix-warning.patch12
-rw-r--r--www-servers/varnish/files/varnishd.confd-r122
-rw-r--r--www-servers/varnish/files/varnishd.confd-r226
-rw-r--r--www-servers/varnish/files/varnishd.confd-r322
-rwxr-xr-xwww-servers/varnish/files/varnishd.initd-r187
-rwxr-xr-xwww-servers/varnish/files/varnishd.initd-r294
-rw-r--r--www-servers/varnish/files/varnishd.initd-r378
-rw-r--r--www-servers/varnish/files/varnishd.logrotate9
-rw-r--r--www-servers/varnish/files/varnishd.logrotate-r231
-rw-r--r--www-servers/varnish/files/varnishd.service16
-rw-r--r--www-servers/varnish/files/varnishlog.confd3
-rw-r--r--www-servers/varnish/files/varnishlog.initd32
-rw-r--r--www-servers/varnish/files/varnishncsa.confd3
-rw-r--r--www-servers/varnish/files/varnishncsa.initd32
-rw-r--r--www-servers/varnish/files/varnishncsa.initd-r145
23 files changed, 721 insertions, 0 deletions
diff --git a/www-servers/varnish/files/varnish-3.0.3-pthread-uclibc.patch b/www-servers/varnish/files/varnish-3.0.3-pthread-uclibc.patch
new file mode 100644
index 00000000000..93f3da3f878
--- /dev/null
+++ b/www-servers/varnish/files/varnish-3.0.3-pthread-uclibc.patch
@@ -0,0 +1,35 @@
+Refine header check in bin/varnishd/mgt/mgt.h, mgt_main.c for uClibc
+
+Because of the difference in how uClibc and glibc stack their header
+files, stdio.h indirectly brings in PTHREAD_CANCELED from pthread.h
+on a uClibc system, whereas it does not on a glibc system. This happens
+in mgt.h and mgt_main.c. This patch refines the check in those files
+to take this fact into consideration.
+
+X-Gentoo-Bug-URL: https://bugs.gentoo.org/444294
+---
+
+diff --git a/bin/varnishd/mgt.h b/bin/varnishd/mgt.h
+index 905fbcc..5d3ab09 100644
+--- a/bin/varnishd/mgt.h
++++ b/bin/varnishd/mgt.h
+@@ -126,6 +126,6 @@ extern unsigned mgt_vcc_unsafe_path;
+ syslog(pri, fmt, __VA_ARGS__); \
+ } while (0)
+
+-#if defined(PTHREAD_CANCELED) || defined(PTHREAD_MUTEX_DEFAULT)
++#if (defined(PTHREAD_CANCELED) && !defined(__UCLIBC__)) || defined(PTHREAD_MUTEX_DEFAULT)
+ #error "Keep pthreads out of in manager process"
+ #endif
+diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c
+index 1b7f1e3..dce42d9 100644
+--- a/bin/varnishd/varnishd.c
++++ b/bin/varnishd/varnishd.c
+@@ -656,6 +656,6 @@ main(int argc, char * const *argv)
+ exit(exit_status);
+ }
+
+-#if defined(PTHREAD_CANCELED) || defined(PTHREAD_MUTEX_DEFAULT)
++#if (defined(PTHREAD_CANCELED) && !defined(__UCLIBC__)) || defined(PTHREAD_MUTEX_DEFAULT)
+ #error "Keep pthreads out of in manager process"
+ #endif
diff --git a/www-servers/varnish/files/varnish-3.0.4-automagic.patch b/www-servers/varnish/files/varnish-3.0.4-automagic.patch
new file mode 100644
index 00000000000..6a517cc9efe
--- /dev/null
+++ b/www-servers/varnish/files/varnish-3.0.4-automagic.patch
@@ -0,0 +1,94 @@
+diff -Naur varnish-3.0.4.orig/configure.ac varnish-3.0.4/configure.ac
+--- varnish-3.0.4.orig/configure.ac 2013-06-14 04:39:32.000000000 -0400
++++ varnish-3.0.4/configure.ac 2013-06-15 23:51:51.000000000 -0400
+@@ -87,15 +87,20 @@
+
+ save_LIBS="${LIBS}"
+ LIBS=""
+-AC_SEARCH_LIBS(initscr, [curses ncurses],
+- [have_curses=yes], [have_curses=no])
+-CURSES_LIBS="${LIBS}"
+-LIBS="${save_LIBS}"
+-AC_SUBST(CURSES_LIBS)
+-if test "$have_curses" = no; then
+- AC_MSG_WARN([curses not found; some tools will not be built])
+-fi
+-AC_CHECK_HEADERS([ncurses/curses.h curses.h])
++AC_ARG_WITH([tools], AS_HELP_STRING([--without-tools],
++ [Don't build additional tools: varnishhist, varnishstat, varnishtop, varnishsizes (default: test)]))
++
++AS_IF([test "x$with_tools" != "xno"], [
++ AC_SEARCH_LIBS(initscr, [curses ncurses],
++ [have_curses=yes], [have_curses=no])
++ CURSES_LIBS="${LIBS}"
++ LIBS="${save_LIBS}"
++ AC_SUBST(CURSES_LIBS)
++ if test "$have_curses" = no; then
++ AC_MSG_ERROR([curses not found, required to build additional tools])
++ fi
++ AC_CHECK_HEADERS([ncurses/curses.h curses.h])
++])
+ AM_CONDITIONAL([HAVE_CURSES], [test x$have_curses = xyes])
+
+ save_LIBS="${LIBS}"
+@@ -266,7 +271,6 @@
+ CFLAGS="${save_CFLAGS}"
+
+ # Use jemalloc on Linux
+-JEMALLOC_SUBDIR=
+ JEMALLOC_LDADD=
+ AC_ARG_WITH([jemalloc],
+ [AS_HELP_STRING([--with-jemalloc],
+@@ -274,18 +278,13 @@
+ [],
+ [with_jemalloc=check])
+
+-case $target in
+- *-*-linux*)
+- if test "x$with_jemalloc" != xno; then
+- AC_CHECK_LIB([jemalloc], [malloc_conf],
++if test "x$with_jemalloc" != xno; then
++ AC_CHECK_LIB([jemalloc], [malloc_conf],
++ [JEMALLOC_LDADD="-ljemalloc"],
++ [AC_CHECK_LIB([jemalloc], [jmalloc_conf],
+ [JEMALLOC_LDADD="-ljemalloc"],
+- [AC_MSG_NOTICE([No system jemalloc found, using bundled version])
+- JEMALLOC_SUBDIR=libjemalloc
+- JEMALLOC_LDADD='$(top_builddir)/lib/libjemalloc/libjemalloc_mt.la'])
+- fi
+- ;;
+-esac
+-AC_SUBST(JEMALLOC_SUBDIR)
++ [AC_MSG_ERROR([No system jemalloc found])])])
++fi
+ AC_SUBST(JEMALLOC_LDADD)
+
+ # Userland slab allocator, available only on Solaris
+@@ -588,7 +587,6 @@
+ lib/libvcl/Makefile
+ lib/libvgz/Makefile
+ lib/libvmod_std/Makefile
+- lib/libjemalloc/Makefile
+ man/Makefile
+ redhat/Makefile
+ varnishapi.pc
+--- varnish-3.0.4.orig/lib/Makefile.am 2013-06-14 04:39:32.000000000 -0400
++++ varnish-3.0.4/lib/Makefile.am 2013-06-15 23:51:08.000000000 -0400
+@@ -6,14 +6,12 @@
+ libvarnishapi \
+ libvcl \
+ libvgz \
+- libvmod_std \
+- @JEMALLOC_SUBDIR@
++ libvmod_std
+
+-DIST_SUBDIRS = \
++DIST_SUBDIRS = \
+ libvarnishcompat \
+ libvarnish \
+ libvarnishapi \
+ libvcl \
+ libvgz \
+- libvmod_std \
+- libjemalloc
++ libvmod_std
diff --git a/www-servers/varnish/files/varnish-3.0.4-fix-automake-1.13.patch b/www-servers/varnish/files/varnish-3.0.4-fix-automake-1.13.patch
new file mode 100644
index 00000000000..0034c807139
--- /dev/null
+++ b/www-servers/varnish/files/varnish-3.0.4-fix-automake-1.13.patch
@@ -0,0 +1,12 @@
+diff -Naur varnish-3.0.4.orig/configure.ac varnish-3.0.4/configure.ac
+--- varnish-3.0.4.orig/configure.ac 2013-06-14 04:39:32.000000000 -0400
++++ varnish-3.0.4/configure.ac 2013-06-21 08:48:32.000000000 -0400
+@@ -4,7 +4,7 @@
+ AC_REVISION([$Id: varnish-3.0.4-fix-automake-1.13.patch,v 1.1 2013/06/21 12:51:35 blueness Exp $])
+ AC_INIT([Varnish], [3.0.4], [varnish-dev@varnish-cache.org])
+ AC_CONFIG_SRCDIR(include/varnishapi.h)
+-AM_CONFIG_HEADER(config.h)
++AC_CONFIG_HEADERS(config.h)
+
+ # save command line CFLAGS for use in VCC_CC (to pass through things like -m64)
+ OCFLAGS="$CFLAGS"
diff --git a/www-servers/varnish/files/varnish-3.0.5-fix-python-path.patch b/www-servers/varnish/files/varnish-3.0.5-fix-python-path.patch
new file mode 100644
index 00000000000..4c927e364a6
--- /dev/null
+++ b/www-servers/varnish/files/varnish-3.0.5-fix-python-path.patch
@@ -0,0 +1,9 @@
+diff -Naur varnish-3.0.5.orig/lib/libvmod_std/vmod.py varnish-3.0.5/lib/libvmod_std/vmod.py
+--- varnish-3.0.5.orig/lib/libvmod_std/vmod.py 2013-12-02 02:47:57.000000000 -0500
++++ varnish-3.0.5/lib/libvmod_std/vmod.py 2014-01-16 13:21:50.763238020 -0500
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/python
++#!/usr/bin/python
+ #-
+ # Copyright (c) 2010-2011 Varnish Software AS
+ # All rights reserved.
diff --git a/www-servers/varnish/files/varnish-3.0.5-path-to-vmod_vcc.patch b/www-servers/varnish/files/varnish-3.0.5-path-to-vmod_vcc.patch
new file mode 100644
index 00000000000..479e007938b
--- /dev/null
+++ b/www-servers/varnish/files/varnish-3.0.5-path-to-vmod_vcc.patch
@@ -0,0 +1,12 @@
+diff -Naur varnish-3.0.5.orig/lib/libvmod_std/vmod.py varnish-3.0.5/lib/libvmod_std/vmod.py
+--- varnish-3.0.5.orig/lib/libvmod_std/vmod.py 2014-01-16 13:33:02.983247069 -0500
++++ varnish-3.0.5/lib/libvmod_std/vmod.py 2014-01-16 13:42:36.848254794 -0500
+@@ -43,7 +43,7 @@
+ if len(sys.argv) == 2:
+ specfile = sys.argv[1]
+ else:
+- specfile = "vmod.vcc"
++ specfile = "/etc/varnish/vmod.vcc"
+
+ ctypes = {
+ 'IP': "struct sockaddr_storage *",
diff --git a/www-servers/varnish/files/varnish-4.0.0-fix-man-Makefile_am.patch b/www-servers/varnish/files/varnish-4.0.0-fix-man-Makefile_am.patch
new file mode 100644
index 00000000000..311f0fd7c95
--- /dev/null
+++ b/www-servers/varnish/files/varnish-4.0.0-fix-man-Makefile_am.patch
@@ -0,0 +1,14 @@
+diff -Naur varnish-4.0.0.orig/man/Makefile.am varnish-4.0.0/man/Makefile.am
+--- varnish-4.0.0.orig/man/Makefile.am 2014-04-12 18:25:35.435043191 -0400
++++ varnish-4.0.0/man/Makefile.am 2014-04-12 18:25:58.579043997 -0400
+@@ -84,8 +84,8 @@
+ $(top_srcdir)/doc/sphinx/include/varnishhist_synopsis.rst
+ ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@
+
+-vmod_std.3: $(top_srcdir)/lib/libvmod_std/vmod_std.man.rst
++vmod_std.3: $(top_builddir)/lib/libvmod_std/vmod_std.man.rst
+ ${RST2MAN} $? $@
+
+-vmod_directors.3: $(top_srcdir)/lib/libvmod_directors/vmod_directors.man.rst
++vmod_directors.3: $(top_builddir)/lib/libvmod_directors/vmod_directors.man.rst
+ ${RST2MAN} $? $@
diff --git a/www-servers/varnish/files/varnish-4.0.1-fix-doc-Makefile_am.patch b/www-servers/varnish/files/varnish-4.0.1-fix-doc-Makefile_am.patch
new file mode 100644
index 00000000000..57885c6488e
--- /dev/null
+++ b/www-servers/varnish/files/varnish-4.0.1-fix-doc-Makefile_am.patch
@@ -0,0 +1,14 @@
+diff -Naur varnish-4.0.1.orig/man/Makefile.am varnish-4.0.1/man/Makefile.am
+--- varnish-4.0.1.orig/man/Makefile.am 2014-06-23 09:43:06.000000000 -0400
++++ varnish-4.0.1/man/Makefile.am 2014-06-25 08:40:43.498765372 -0400
+@@ -86,8 +86,8 @@
+ $(top_srcdir)/doc/sphinx/include/varnishhist_synopsis.rst
+ ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@
+
+-vmod_std.3: $(top_srcdir)/lib/libvmod_std/vmod_std.man.rst
++vmod_std.3: $(top_builddir)/lib/libvmod_std/vmod_std.man.rst
+ ${RST2MAN} $(RST2ANY_FLAGS) $? $@
+
+-vmod_directors.3: $(top_srcdir)/lib/libvmod_directors/vmod_directors.man.rst
++vmod_directors.3: $(top_builddir)/lib/libvmod_directors/vmod_directors.man.rst
+ ${RST2MAN} $(RST2ANY_FLAGS) $? $@
diff --git a/www-servers/varnish/files/varnish-4.0.1-fix-man-Makefile_am.patch b/www-servers/varnish/files/varnish-4.0.1-fix-man-Makefile_am.patch
new file mode 100644
index 00000000000..c65fba2391e
--- /dev/null
+++ b/www-servers/varnish/files/varnish-4.0.1-fix-man-Makefile_am.patch
@@ -0,0 +1,19 @@
+diff -Naur varnish-4.0.1.orig/doc/sphinx/Makefile.am varnish-4.0.1/doc/sphinx/Makefile.am
+--- varnish-4.0.1.orig/doc/sphinx/Makefile.am 2014-06-23 09:43:06.000000000 -0400
++++ varnish-4.0.1/doc/sphinx/Makefile.am 2014-06-25 08:35:11.887750279 -0400
+@@ -144,11 +144,13 @@
+ BUILT_SOURCES += include/varnishhist_options.rst \
+ include/varnishhist_synopsis.rst
+
+-reference/vmod_std.generated.rst: $(top_srcdir)/lib/libvmod_std/vmod_std.rst
++reference/vmod_std.generated.rst: $(top_builddir)/lib/libvmod_std/vmod_std.rst
++ mkdir -p reference
+ cp $? $@
+ BUILT_SOURCES += reference/vmod_std.generated.rst
+
+-reference/vmod_directors.generated.rst: $(top_srcdir)/lib/libvmod_directors/vmod_directors.rst
++reference/vmod_directors.generated.rst: $(top_builddir)/lib/libvmod_directors/vmod_directors.rst
++ mkdir -p reference
+ cp $? $@
+ BUILT_SOURCES += reference/vmod_directors.generated.rst
+
diff --git a/www-servers/varnish/files/varnish-4.0.1-fix-warning.patch b/www-servers/varnish/files/varnish-4.0.1-fix-warning.patch
new file mode 100644
index 00000000000..ae327292fb7
--- /dev/null
+++ b/www-servers/varnish/files/varnish-4.0.1-fix-warning.patch
@@ -0,0 +1,12 @@
+diff -Naur /root/varnish-4.0.1/lib/libvcc/vcc_expr.c varnish-4.0.1/lib/libvcc/vcc_expr.c
+--- /root/varnish-4.0.1/lib/libvcc/vcc_expr.c 2014-06-25 07:06:42.550508615 -0400
++++ varnish-4.0.1/lib/libvcc/vcc_expr.c 2014-06-23 09:43:06.000000000 -0400
+@@ -670,7 +670,7 @@
+ struct expr *e1, *e2;
+ const char *ip;
+ const struct symbol *sym;
+- double d;
++ double d = 0.0;
+
+ *e = NULL;
+ if (tl->t->tok == '(') {
diff --git a/www-servers/varnish/files/varnishd.confd-r1 b/www-servers/varnish/files/varnishd.confd-r1
new file mode 100644
index 00000000000..472b26f9942
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.confd-r1
@@ -0,0 +1,22 @@
+# /etc/conf.d/varnishd
+
+VARNISHD="/usr/sbin/varnishd"
+VARNISHADM="/usr/bin/varnishadm"
+CONFIGFILE="/etc/varnish/default.vcl"
+
+# Listen on 127.0.0.1:8080 and connect to backend 127.0.0.1:80
+# Ignore the config file, /etc/varnish/default.vcl
+VARNISHD_OPTS="-a 127.0.0.1:8080 -b 127.0.0.1:80"
+
+# Alternatively, don't listen to a backend and use
+# the config file
+#VARNISHD_OPTS="-a 127.0.0.1:8080 -f $CONFIGFILE"
+
+# arguments passed to varnishncsa
+# please see the varnishncsa man page for more options
+VARNISHNCSA_ARGS="-c -a -w /var/log/varnish/access.log"
+
+# We need to increase the number of open files (-n)
+# and the maximum amount off locked memory (-l)
+# See bug #459142
+rc_ulimit="-n 32786 -l 82000"
diff --git a/www-servers/varnish/files/varnishd.confd-r2 b/www-servers/varnish/files/varnishd.confd-r2
new file mode 100644
index 00000000000..699bc8e57d6
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.confd-r2
@@ -0,0 +1,26 @@
+# /etc/conf.d/varnishd
+
+VARNISHD="/usr/sbin/varnishd"
+VARNISHADM="/usr/bin/varnishadm"
+CONFIGFILE="/etc/varnish/default.vcl"
+
+# Listen on 127.0.0.1:8080 and connect to backend 127.0.0.1:80
+# Ignore the config file, /etc/varnish/default.vcl
+VARNISHD_OPTS="-a 127.0.0.1:8080 -b 127.0.0.1:80"
+
+# Alternatively, don't listen to a backend and use
+# the config file
+#VARNISHD_OPTS="-a 127.0.0.1:8080 -f $CONFIGFILE"
+
+# Arguments passed to varnishncsa
+# Please see varnishncsa(1) for more options
+VARNISHNCSA_ARGS="-c -a -w /var/log/varnish/access.log"
+
+# Arguments passed to varnishncsa -F option
+# Please see varnishncsa(1) for more options
+# VARNISHNCSA_LOGFORMAT='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i"'
+
+# We need to increase the number of open files (-n)
+# and the maximum amount off locked memory (-l)
+# See bug #459142
+rc_ulimit="-n 32786 -l 82000"
diff --git a/www-servers/varnish/files/varnishd.confd-r3 b/www-servers/varnish/files/varnishd.confd-r3
new file mode 100644
index 00000000000..c05b8fb7521
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.confd-r3
@@ -0,0 +1,22 @@
+# /etc/conf.d/varnishd
+
+VARNISHD="/usr/sbin/varnishd"
+VARNISHADM="/usr/bin/varnishadm"
+
+#CONFIGFILES="/etc/varnish/${SVCNAME}.vcl"
+CONFIGFILE="/etc/varnish/default.vcl"
+
+# Listen on 127.0.0.1:8080 and connect to backend 127.0.0.1:80
+#VARNISHD_OPTS="-a 127.0.0.1:8080 -a 127.0.0.1:8080"
+
+# Alternatively, don't listen to a backend
+VARNISHD_OPTS="-a 127.0.0.1:8080"
+
+
+# User/Group
+VARNISHD_OPTS="${VARNISHD_OPTS} -u varnish -g varnish"
+
+# You may need to increase the number of open files (-n)
+# and the maximum amount off locked memory (-l)
+# See bug #459142
+#rc_ulimit="-n 32786 -l 82000"
diff --git a/www-servers/varnish/files/varnishd.initd-r1 b/www-servers/varnish/files/varnishd.initd-r1
new file mode 100755
index 00000000000..54487ca6e9e
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.initd-r1
@@ -0,0 +1,87 @@
+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+extra_commands="configtest"
+extra_started_commands="reload"
+
+description_configtest="Run syntax tests for configuration files."
+description_reload="Reloads the configuration."
+
+depend() {
+ need net
+}
+
+configtest() {
+ ebegin "Checking ${SVCNAME} configuration"
+ checkconfig
+ eend $?
+}
+
+checkconfig() {
+ ${VARNISHD} -C -f ${CONFIGFILE} >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} has detected an error in your setup:"
+ ${VARNISHD} -C -f ${CONFIGFILE}
+ fi
+
+ return $ret
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting varnish"
+ start-stop-daemon --quiet --start --pidfile /var/run/varnishd.pid --exec ${VARNISHD} -- -P /var/run/varnishd.pid ${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}
+ eend $?
+ fi
+}
+
+stop() {
+ ebegin "Stopping varnish"
+ start-stop-daemon --quiet --stop --pidfile /var/run/varnishd.pid
+ eend $?
+
+ if [ -e /var/run/varnishncsa.pid ]; then
+ ebegin "Stopping varnish logging"
+ start-stop-daemon --quiet --stop --pidfile /var/run/varnishncsa.pid
+ eend $?
+ fi
+}
+
+reload() {
+ checkconfig || return 1
+
+ ebegin "Reloading varnish"
+
+ $VARNISHADM vcl.list >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot list configuration"
+ return 1
+ fi
+
+ new_config="reload_$(date +%FT%H:%M:%S)"
+ $VARNISHADM vcl.load $new_config $CONFIGFILE >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot load configuration"
+ return 1
+ fi
+
+ $VARNISHADM vcl.use $new_config >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot switch configuration"
+ return 1
+ fi
+
+ eend 0
+}
diff --git a/www-servers/varnish/files/varnishd.initd-r2 b/www-servers/varnish/files/varnishd.initd-r2
new file mode 100755
index 00000000000..055a9ec0405
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.initd-r2
@@ -0,0 +1,94 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+extra_commands="configtest"
+extra_started_commands="reload"
+
+description_configtest="Run syntax tests for configuration files."
+description_reload="Reloads the configuration."
+
+depend() {
+ need net
+}
+
+configtest() {
+ ebegin "Checking ${SVCNAME} configuration"
+ checkconfig
+ eend $?
+}
+
+checkconfig() {
+ ${VARNISHD} -C -f ${CONFIGFILE} >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} has detected an error in your setup:"
+ ${VARNISHD} -C -f ${CONFIGFILE}
+ fi
+
+ return $ret
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting varnish"
+ start-stop-daemon --quiet --start --pidfile /run/varnishd.pid \
+ --exec ${VARNISHD} -- \
+ -P /run/varnishd.pid \
+ ${VARNISHD_OPTS} &> /dev/null
+ eend $?
+
+ if [ "${VARNISHNCSA_ARGS}" != "" ]; then
+ ebegin "Starting varnish logging"
+ start-stop-daemon --quiet --start --pidfile /run/varnishncsa.pid \
+ --exec /usr/bin/varnishncsa -- \
+ -D -P /run/varnishncsa.pid \
+ ${VARNISHNCSA_ARGS} \
+ ${VARNISHNCSA_LOGFORMAT:+-F "${VARNISHNCSA_LOGFORMAT}"}
+ eend $?
+ fi
+}
+
+stop() {
+ ebegin "Stopping varnish"
+ start-stop-daemon --quiet --stop --pidfile /run/varnishd.pid
+ eend $?
+
+ if [ -e /run/varnishncsa.pid ]; then
+ ebegin "Stopping varnish logging"
+ start-stop-daemon --quiet --stop --pidfile /run/varnishncsa.pid
+ eend $?
+ fi
+}
+
+reload() {
+ checkconfig || return 1
+
+ ebegin "Reloading varnish"
+
+ $VARNISHADM vcl.list >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot list configuration"
+ return 1
+ fi
+
+ new_config="reload_$(date +%FT%H:%M:%S)"
+ $VARNISHADM vcl.load $new_config $CONFIGFILE >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot load configuration"
+ return 1
+ fi
+
+ $VARNISHADM vcl.use $new_config >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot switch configuration"
+ return 1
+ fi
+
+ eend 0
+}
diff --git a/www-servers/varnish/files/varnishd.initd-r3 b/www-servers/varnish/files/varnishd.initd-r3
new file mode 100644
index 00000000000..4a7dcb9d0ad
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.initd-r3
@@ -0,0 +1,78 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+VARNISHD_PID=${VARNISHD_PID:-/run/${SVCNAME}.pid}
+CONFIGFILES="${CONFIGFILE:-/etc/varnish/default.vcl}"
+
+command="${VARNISHD:-/usr/sbin/varnishd}"
+command_args="-P ${VARNISHD_PID} -f ${CONFIGFILE} ${VARNISHD_OPTS}"
+pidfile="${VARNISHD_PID}"
+
+extra_commands="configtest"
+extra_started_commands="reload"
+
+description_configtest="Run syntax tests for configuration files."
+description_reload="Reloads the configuration."
+
+depend() {
+ need net
+}
+
+configtest() {
+ ebegin "Checking ${SVCNAME} configuration"
+ checkconfig
+ eend $?
+}
+
+checkconfig() {
+ ${VARNISHD} -C -f ${CONFIGFILE} >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} has detected an error in your setup:"
+ ${VARNISHD} -C -f ${CONFIGFILE}
+ fi
+
+ return $ret
+}
+
+start_pre() {
+ checkconfig || return 1
+}
+
+stop_pre() {
+ if [ "${RC_CMD}" = "restart" ]; then
+ checkconfig || return 1
+ fi
+}
+
+reload() {
+ checkconfig || return 1
+
+ ebegin "Reloading varnish"
+
+ $VARNISHADM vcl.list >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot list configuration"
+ return 1
+ fi
+
+ new_config="reload_$(date +%FT%H:%M:%S)"
+ $VARNISHADM vcl.load $new_config $CONFIGFILE >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot load configuration"
+ return 1
+ fi
+
+ $VARNISHADM vcl.use $new_config >/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} cannot switch configuration"
+ return 1
+ fi
+
+ eend 0
+}
diff --git a/www-servers/varnish/files/varnishd.logrotate b/www-servers/varnish/files/varnishd.logrotate
new file mode 100644
index 00000000000..62ee60007a2
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.logrotate
@@ -0,0 +1,9 @@
+/var/log/varnish/*.log {
+ weekly
+ rotate 10
+ copytruncate
+ delaycompress
+ compress
+ notifempty
+ missingok
+}
diff --git a/www-servers/varnish/files/varnishd.logrotate-r2 b/www-servers/varnish/files/varnishd.logrotate-r2
new file mode 100644
index 00000000000..e697e428f3d
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.logrotate-r2
@@ -0,0 +1,31 @@
+/var/log/varnish/varnishncsa.log {
+ daily
+ rotate 31
+ copytruncate
+ dateext
+ dateyesterday
+ delaycompress
+ compress
+ notifempty
+ missingok
+
+ prerotate
+ /etc/init.d/varnishncsa -q status && /etc/init.d/varnishncsa -q flush
+ endscript
+}
+
+/var/log/varnish/varnishlog.log {
+ daily
+ rotate 31
+ copytruncate
+ dateext
+ dateyesterday
+ delaycompress
+ compress
+ notifempty
+ missingok
+
+ prerotate
+ /etc/init.d/varnishlog -q status && /etc/init.d/varnishlog -q flush
+ endscript
+}
diff --git a/www-servers/varnish/files/varnishd.service b/www-servers/varnish/files/varnishd.service
new file mode 100644
index 00000000000..a45f1e24783
--- /dev/null
+++ b/www-servers/varnish/files/varnishd.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Varnish is a high-performance HTTP accelerator
+After=network.target
+
+[Service]
+Type=forking
+LimitNOFILE=32786
+LimitMEMLOCK=82000
+PIDFile=/var/run/varnishd.pid
+ExecStart=/usr/sbin/varnishd -a 0.0.0.0:80 -P /var/run/varnishd.pid
+
+#If you wish to use a config file, then use the following ExecStart line
+#ExecStart=/usr/sbin/varnishd -a 0.0.0.0:80 -f /etc/varnish/default.vcl -P /var/run/varnishd.pid
+
+[Install]
+WantedBy=multi-user.target
diff --git a/www-servers/varnish/files/varnishlog.confd b/www-servers/varnish/files/varnishlog.confd
new file mode 100644
index 00000000000..d7358b1dc89
--- /dev/null
+++ b/www-servers/varnish/files/varnishlog.confd
@@ -0,0 +1,3 @@
+# /etc/conf.d/varnishlog
+
+VARNISHLOG_OPTS="-a -w /var/log/varnish/varnishlog.log"
diff --git a/www-servers/varnish/files/varnishlog.initd b/www-servers/varnish/files/varnishlog.initd
new file mode 100644
index 00000000000..fae8297743f
--- /dev/null
+++ b/www-servers/varnish/files/varnishlog.initd
@@ -0,0 +1,32 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+VARNISHLOG_PID=${VARNISHLOG_PID:-/run/${SVCNAME}.pid}
+
+command="${VARNISHLOG:-/usr/bin/varnishlog}"
+command_args="-D -P ${VARNISHLOG_PID} ${VARNISHLOG_OPTS}"
+pidfile="${VARNISHLOG_PID}"
+
+extra_started_commands="reload rotate flush"
+
+description_rotate="Rotate the log file"
+description_flush="Flush any outstanding transactions"
+
+rotate() {
+ ebegin "Rotating log file"
+ start-stop-daemon -p ${VARNISHLOG_PID} -s SIGHUP
+ eend $?
+}
+
+flush() {
+ ebegin "Flushing any outstanding transactions"
+ start-stop-daemon -p ${VARNISHLOG_PID} -s SIGUSR1
+ eend $?
+}
+
+reload() {
+ flush
+ rotate
+}
diff --git a/www-servers/varnish/files/varnishncsa.confd b/www-servers/varnish/files/varnishncsa.confd
new file mode 100644
index 00000000000..f3112fdd532
--- /dev/null
+++ b/www-servers/varnish/files/varnishncsa.confd
@@ -0,0 +1,3 @@
+# /etc/conf.d/varnishncsa
+
+VARNISHNCSA_OPTS="-a -w /var/log/varnish/${SVCNAME}.log"
diff --git a/www-servers/varnish/files/varnishncsa.initd b/www-servers/varnish/files/varnishncsa.initd
new file mode 100644
index 00000000000..7b38397670d
--- /dev/null
+++ b/www-servers/varnish/files/varnishncsa.initd
@@ -0,0 +1,32 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+VARNISHNCSA_PID=${VARNISHNCSA_PID:-/run/${SVCNAME}.pid}
+
+command="${VARNISHNCSA:-/usr/bin/varnishncsa}"
+command_args="-D -P ${VARNISHNCSA_PID} ${VARNISHNCSA_OPTS}"
+pidfile="${VARNISHNCSA_PID}"
+
+extra_started_commands="reload rotate flush"
+
+description_rotate="Rotate the log file"
+description_flush="Flush any outstanding transactions"
+
+rotate() {
+ ebegin "Rotating log file"
+ start-stop-daemon -p ${VARNISHNCSA_PID} -s SIGHUP
+ eend $?
+}
+
+flush() {
+ ebegin "Flushing any outstanding transactions"
+ start-stop-daemon -p ${VARNISHNCSA_PID} -s SIGUSR1
+ eend $?
+}
+
+reload() {
+ flush
+ rotate
+}
diff --git a/www-servers/varnish/files/varnishncsa.initd-r1 b/www-servers/varnish/files/varnishncsa.initd-r1
new file mode 100644
index 00000000000..e06a5945afb
--- /dev/null
+++ b/www-servers/varnish/files/varnishncsa.initd-r1
@@ -0,0 +1,45 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+VARNISHNCSA_PID=${VARNISHNCSA_PID:-/run/${SVCNAME}.pid}
+
+command="${VARNISHNCSA:-/usr/bin/varnishncsa}"
+command_args="-D -P ${VARNISHNCSA_PID} ${VARNISHNCSA_OPTS}"
+pidfile="${VARNISHNCSA_PID}"
+
+extra_started_commands="reload rotate flush"
+
+description_rotate="Rotate the log file"
+description_flush="Flush any outstanding transactions"
+
+# We need to make sure varnishd has started first, bug #524284
+start_pre() {
+ TIMEOUT=${TIMEOUT:-5}
+
+ local i=0
+ while [ $i -lt ${TIMEOUT} ]; do
+ echo status | varnishadm 2>/dev/null | grep -q "Child in state running"
+ test $? -eq 0 && break
+
+ sleep 1 && i=$(expr $i + 1)
+ done
+}
+
+rotate() {
+ ebegin "Rotating log file"
+ start-stop-daemon -p ${VARNISHNCSA_PID} -s SIGHUP
+ eend $?
+}
+
+flush() {
+ ebegin "Flushing any outstanding transactions"
+ start-stop-daemon -p ${VARNISHNCSA_PID} -s SIGUSR1
+ eend $?
+}
+
+reload() {
+ flush
+ rotate
+}