Ticket #39477: 0003-Add-scripts-to-make-the-administration-more-easer.patch
File 0003-Add-scripts-to-make-the-administration-more-easer.patch, 6.4 KB (added by robsonpeixoto@…, 11 years ago) |
---|
-
Portfile
From bf0bb4e8e59fcc8f8b6d76b1d3f44014de99fb57 Mon Sep 17 00:00:00 2001 From: Robson Peixoto <robsonpeixoto@gmail.com> Date: Wed, 19 Jun 2013 23:52:55 -0300 Subject: [PATCH 4/4] Add scripts to make the administration more easer - Add reload vlc script from archlinux - Add varnish.conf file (make config easer) - Add init script (need to varnish.conf work) --- Portfile | 82 +++++++++++++++++++++++++++++++++++---------- files/varnish-vcl-reload.in | 20 +++++++++++ files/varnish.conf.in | 11 ++++++ files/varnish.init.in | 35 +++++++++++++++++++ 4 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 files/varnish-vcl-reload.in create mode 100644 files/varnish.conf.in create mode 100644 files/varnish.init.in diff --git a/Portfile b/Portfile index 49e3b1b..1e5a922 100644
a b 1 1 # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 # $Id $2 # $Id: Portfile 97982 2012-09-21 09:00:27Z ryandesign@macports.org $ 3 3 4 PortSystem 1.04 PortSystem 1.0 5 5 6 name varnish7 epoch 201107098 version 3.0.49 categories www10 license BSD zlib 11 platforms darwin 12 maintainers pmq openmaintainer 6 name varnish 7 epoch 20110709 8 version 3.0.4 9 categories www 10 platforms darwin 11 maintainers pmq openmaintainer 12 license BSD 13 13 14 description Varnish is a state-of-the-art, high-performance HTTP accelerator15 long_description Varnish was written from the ground up to be a high \16 performance caching reverse proxy.14 description Varnish is a state-of-the-art, high-performance HTTP accelerator 15 long_description Varnish was written from the ground up to be a high \ 16 performance caching reverse proxy. 17 17 18 homepage http://www.varnish-cache.org19 master_sites http://repo.varnish-cache.org/source/18 homepage http://www.varnish-cache.org 19 master_sites http://repo.varnish-cache.org/source/ 20 20 21 checksums rmd160 ed8aba21af17d5fee225eb03950fd90ad7b07911 \22 sha256 4e044ccb5c76222bddf89c808f13ea8f66977972675aecb48a920f6800ad0f7921 checksums rmd160 ed8aba21af17d5fee225eb03950fd90ad7b07911 \ 22 sha256 4e044ccb5c76222bddf89c808f13ea8f66977972675aecb48a920f6800ad0f79 23 23 24 depends_build port:pkgconfig 24 depends_build port:pkgconfig \ 25 port:py27-docutils 25 26 26 depends_lib port:pcre 27 depends_lib port:pcre 28 29 configure.args-append --with-rst2man=${prefix}/bin/rst2man-2.7.py 30 31 startupitem.create yes 32 startupitem.pidfile auto "${prefix}/var/run/${name}/${name}.pid" 33 startupitem.start "${prefix}/share/${name}/varnish.init start" 34 startupitem.stop "${prefix}/share/${name}/varnish.init stop" 35 startupitem.restart "${prefix}/share/${name}/varnish.init restart" 36 37 post-destroot { 38 # create dir 39 xinstall -d -m 755 ${destroot}${prefix}/share/${name} 40 41 # copy files 42 xinstall -m 644 ${filespath}/varnish.conf.in ${destroot}${prefix}/etc/${name}/varnish.conf.default 43 xinstall -m 755 ${filespath}/varnish.init.in ${destroot}${prefix}/share/${name}/${name}.init 44 xinstall -m 755 ${filespath}/varnish-vcl-reload.in ${destroot}${prefix}/sbin/varnish-vcl-reload 45 46 # replace @PREFIX@ to ${prefix} 47 reinplace "s|@PREFIX@|${prefix}|g" \ 48 ${destroot}${prefix}/etc/${name}/varnish.conf.default \ 49 ${destroot}${prefix}/share/${name}/${name}.init \ 50 ${destroot}${prefix}/sbin/varnish-vcl-reload 51 52 file rename ${destroot}${prefix}/etc/${name}/default.vcl ${destroot}${prefix}/etc/${name}/default.vcl.default 53 } 54 55 post-activate { 56 if {![file exists ${prefix}/etc/${name}/default.vcl]} { 57 file copy ${prefix}/etc/${name}/default.vcl.default \ 58 ${prefix}/etc/${name}/default.vcl 59 } 60 if {![file exists ${prefix}/etc/${name}/varnish.conf]} { 61 file copy ${prefix}/etc/${name}/varnish.conf.default \ 62 ${prefix}/etc/${name}/varnish.conf 63 } 64 65 # dirs nedded to run varnish 66 xinstall -d -m 755 -o nobody -g nobody ${prefix}/var/${name} 67 xinstall -d -m 755 -o nobody -g nobody ${prefix}/var/run/${name} 68 } 69 70 livecheck.url ${master_sites} 71 livecheck.type regex 72 livecheck.regex ${name}-(\\d+\\.\\d+\\.\\d+).tar.gz -
new file files/varnish-vcl-reload.in
diff --git a/files/varnish-vcl-reload.in b/files/varnish-vcl-reload.in new file mode 100644 index 0000000..f1a9988
- + 1 #!/bin/sh 2 3 cfg=${1:-@PREFIX@/etc/varnish/default.vcl} 4 if [ ! -e "$cfg" ]; then 5 printf 'ERROR: VCL file %s does not exist\n' "$cfg" >&2 6 exit 1 7 fi 8 9 activecfg=$(varnishadm 'vcl.list' | awk '/active/ { print $3 }') 10 if [ -z "$activecfg" ]; then 11 printf 'ERROR: No active VCL found!\n' >&2 12 exit 1 13 fi 14 15 newcfg=$(date +'vcl-%s') 16 printf 'INFO: using new config %s\n' "$cfg" 17 18 varnishadm "vcl.load $newcfg $cfg" && 19 varnishadm "vcl.use $newcfg" && 20 varnishadm "vcl.discard $activecfg" -
new file files/varnish.conf.in
diff --git a/files/varnish.conf.in b/files/varnish.conf.in new file mode 100644 index 0000000..f4c2506
- + 1 # 2 # MANDATORIES command line options to varnishd 3 # 4 5 VARNISH_CFG="@PREFIX@/etc/varnish/default.vcl" 6 7 VARNISHD_OPTS="-a 0.0.0.0:80 8 -f $VARNISH_CFG 9 -T localhost:6082 10 -s malloc,64M 11 -u nobody -g nobody" -
new file files/varnish.init.in
diff --git a/files/varnish.init.in b/files/varnish.init.in new file mode 100644 index 0000000..f5aa0a9
- + 1 #!/bin/bash 2 3 . @PREFIX@/etc/varnish/varnish.conf 4 5 VARNISHD_PID="@PREFIX@/var/run/varnish/varnish.pid" 6 7 if [[ -r $VARNISHD_PID ]]; then 8 read -r PID < "$VARNISHD_PID" 9 ps -p $PID &> /dev/null 10 CHECK=$? 11 if [[ "x$CHECK" == "x1" ]]; then 12 unset PID 13 rm -f "$VARNISHD_PID" 14 fi 15 fi 16 17 case $1 in 18 start) 19 @PREFIX@/sbin/varnishd $VARNISHD_OPTS -P $VARNISHD_PID 20 ;; 21 stop) 22 [[ $PID ]] && kill $PID &>/dev/null 23 ;; 24 restart) 25 $0 stop 26 sleep 1 27 $0 start 28 ;; 29 reload) 30 @PREFIX@/sbin/varnish-vcl-reload $VARNISH_CFG 31 ;; 32 *) 33 echo "usage: $0 {start|stop|restart|reload}" 34 ;; 35 esac