diff options
author | Matt Schurenko <matt.schurenko@gmail.com> | 2011-10-09 03:44:57 -0500 |
---|---|---|
committer | Robby Workman <rworkman@slackbuilds.org> | 2011-10-11 21:20:30 -0500 |
commit | 2b7c9cd06c6963ffae8087b1cce75a96b963073a (patch) | |
tree | aab1a080e4ec604f7310807c3f1650da240e14c8 /network | |
parent | d237cb9dbda73bda305912e90b48f244e2c6bbec (diff) |
network/varnish: Added (a state of the art web application accelerator)
Signed-off-by: Erik Hanson <erik@slackbuilds.org>
Diffstat (limited to 'network')
-rw-r--r-- | network/varnish/README | 8 | ||||
-rw-r--r-- | network/varnish/doinst.sh | 26 | ||||
-rwxr-xr-x | network/varnish/rc.varnishd | 78 | ||||
-rw-r--r-- | network/varnish/slack-desc | 19 | ||||
-rw-r--r-- | network/varnish/varnish.SlackBuild | 90 | ||||
-rw-r--r-- | network/varnish/varnish.info | 10 |
6 files changed, 231 insertions, 0 deletions
diff --git a/network/varnish/README b/network/varnish/README new file mode 100644 index 0000000000000..d8c1194ce9dc6 --- /dev/null +++ b/network/varnish/README @@ -0,0 +1,8 @@ +Varnish Cache is a web application accelerator also known as a caching +HTTP reverse proxy. You install it in front of any server that speaks +HTTP and configure it to cache the contents. + +Varnish is free software licensed under a two-clause BSD licence, also +known as the FreeBSD licence. The project was initiated in 2005. + +Homepage: https://www.varnish-cache.org/ diff --git a/network/varnish/doinst.sh b/network/varnish/doinst.sh new file mode 100644 index 0000000000000..b41b3781b9701 --- /dev/null +++ b/network/varnish/doinst.sh @@ -0,0 +1,26 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + +preserve_perms etc/rc.d/rc.varnishd.new +config etc/varnish/default.vcl.new diff --git a/network/varnish/rc.varnishd b/network/varnish/rc.varnishd new file mode 100755 index 0000000000000..b6354687f7fcc --- /dev/null +++ b/network/varnish/rc.varnishd @@ -0,0 +1,78 @@ +#!/bin/sh + +# varnish rc script +# written by Matt Schurenko <matt.schurenko@gmail.com> + +USAGE="usage: $0 start|stop|restart" +BIN='/usr/sbin/varnishd' +CONF='/etc/varnish/default.vcl' +PID='/var/run/varnish.pid' + +## +# adjust the following variables accordingly +## +BACKING_FILE='/var/lib/varnish-cache' +ADMIN_IP='127.0.0.1' +ADMIN_PORT=8001 +HTTP_IP='0.0.0.0' +HTTP_PORT=80 +CACHE_SIZE='1g' +# ttl assigned to objects without ttl values (default 120s) +DEFAULT_TTL=604800 # 7 days +FILE_DESCRIPTORS=131072 +MIN_THREADS=5 +MAX_THREADS=500 +THREAD_TIMEOUT=300 +# maximum number of http headers (default is 64) +HTTP_HEADERS=384 +# connection timout for backend (default is 0.4s) +CONNECT_TIMEOUT='4.0' + +VARNISH_OPTS="-f $CONF \ + -s file,${BACKING_FILE},$CACHE_SIZE \ + -T $ADMIN_IP:${ADMIN_PORT} \ + -a $HTTP_IP:${HTTP_PORT} \ + -t $DEFAULT_TTL \ + -w${MIN_THREADS},${MAX_THREADS},${THREAD_TIMEOUT} \ + -P $PID" + +VARNISH_PARAMS="-p http_headers=$HTTP_HEADERS \ + -p connect_timeout=$CONNECT_TIMEOUT" + +varnish_start() { + if [ -e $PID ];then + if [ `pgrep varnishd|head -n1` == `cat $PID` ];then + echo "varnish is already running" + exit 1 + else # pid file must be stale + "$PID exists but pid doesn't match pid of varnishd. please investigate." + exit 2 + fi + fi + ulimit -n $FILE_DESCRIPTORS + echo "starting varnish..." + $BIN $VARNISH_OPTS $VARNISH_PARAMS +} +varnish_stop() { + echo "stopping varnish..." + killall `echo $BIN | awk -F'/' '{print $NF}'` + if [ -e $PID ];then + rm $PID + fi +} + +case "$1" in + start) + varnish_start + ;; + stop) + varnish_stop + ;; + restart) + varnish_stop + sleep 1 + varnish_start + ;; + *) echo -e $USAGE + ;; +esac diff --git a/network/varnish/slack-desc b/network/varnish/slack-desc new file mode 100644 index 0000000000000..0f52e48fa1a21 --- /dev/null +++ b/network/varnish/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +varnish: varnish (a state of the art web application accelerator) +varnish: +varnish: Varnish Cache is a web application accelerator also known as a caching +varnish: HTTP reverse proxy. You install it in front of any server that speaks +varnish: HTTP and configure it to cache the contents. +varnish: +varnish: Varnish is free software licensed under a two-clause BSD licence, also +varnish: known as the FreeBSD licence. The project was initiated in 2005. +varnish: +varnish: Homepage: https://www.varnish-cache.org/ +varnish: diff --git a/network/varnish/varnish.SlackBuild b/network/varnish/varnish.SlackBuild new file mode 100644 index 0000000000000..9610c6738e82f --- /dev/null +++ b/network/varnish/varnish.SlackBuild @@ -0,0 +1,90 @@ +#!/bin/sh + +# Slackware build script for varnish-cache + +# Written by Matt Schurenko <matt.schurenko@gmail.com> + +PRGNAM=varnish +VERSION=${VERSION:-2.1.5} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i486 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +set -e # Exit on most errors + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/$PRGNAM-$VERSION.tar.gz +cd $PRGNAM-$VERSION +chown -R root:root . +find . \ + \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ + -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ + -exec chmod 644 {} \; + +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +./autogen.sh + +./configure \ + --prefix=/usr \ + --libdir=/usr/lib${LIBDIRSUFFIX} \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --mandir=/usr/man \ + --docdir=/usr/doc/$PRGNAM-$VERSION \ + --build=$ARCH-slackware-linux + +make +make install DESTDIR=$PKG + +find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +find $PKG/usr/man -type f -exec gzip -9 {} \; + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION + +cp -a doc $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +# copy rc.varnish into ./etc/rc.d/ +mkdir $PKG/etc/rc.d/ +cp -p $CWD/rc.varnishd $PKG/etc/rc.d/rc.varnishd.new +mv $PKG/etc/varnish/default.vcl{,.new} + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/network/varnish/varnish.info b/network/varnish/varnish.info new file mode 100644 index 0000000000000..6db55baee4bf3 --- /dev/null +++ b/network/varnish/varnish.info @@ -0,0 +1,10 @@ +PRGNAM="varnish" +VERSION="2.1.5" +HOMEPAGE="https://www.varnish-cache.org/" +DOWNLOAD="http://repo.varnish-cache.org/source/varnish-2.1.5.tar.gz" +MD5SUM="2d2f227da36a2a240c475304c717b8e3" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +MAINTAINER="Matt Schurenko" +EMAIL="matt.schurenko@gmail.com" +APPROVED="Erik Hanson" |