Ticket #35863: 3.0.3-startupitem-reloadscript.patch

File 3.0.3-startupitem-reloadscript.patch, 5.8 KB (added by robsonpeixoto@…, 12 years ago)

A lot of new things. A status script, a reload script and startupitem.

  • Portfile

     
    11# $Id$
    22
    3 PortSystem            1.0
     3PortSystem                              1.0
    44
    5 name                  varnish
    6 epoch                 20110709
    7 version               3.0.2
    8 revision              1
    9 categories            www
    10 platforms             darwin
    11 maintainers           pmq openmaintainer
     5name                                    varnish
     6epoch                                   20120820
     7version                                 3.0.3
     8revision                                1
     9categories                              www
     10platforms                               darwin
     11maintainers                             pmq openmaintainer
    1212
    13 description           Varnish is a state-of-the-art, high-performance HTTP accelerator
    14 long_description      Varnish was written from the ground up to be a high \
    15                       performance caching reverse proxy.
     13description                             Varnish is a state-of-the-art, high-performance HTTP accelerator
     14long_description                Varnish was written from the ground up to be a high \
     15                                                performance caching reverse proxy.
    1616
    17 homepage              http://www.varnish-cache.org
    18 master_sites          http://repo.varnish-cache.org/source/
     17homepage                                http://www.varnish-cache.org
     18master_sites                    http://repo.varnish-cache.org/source/
    1919
    20 checksums             sha1 906f1536cb7e728d18d9425677907ae723943df7 \
    21                       rmd160 6093839815ba72107fa2b52f0a198167a3a6b79b
     20checksums                               rmd160 a911a2637ef26607aad8a1c34a83bc797a15235d \
     21                                                sha256 2d37d18d952f58b208ac3a0706d4d3e4c0de304b1fcc9df5019571c75f148ab2
    2222
    23 depends_build         port:pkgconfig
     23depends_build                   port:pkgconfig
    2424
    25 depends_lib           port:pcre
     25depends_lib                             port:pcre
     26
     27startupitem.create      yes
     28startupitem.start               "${prefix}/sbin/varnish-server start"
     29startupitem.stop                "${prefix}/sbin/varnish-server stop"
     30startupitem.restart             "${prefix}/sbin/varnish-server restart"
     31
     32post-destroot {
     33    xinstall -m 755 -d "${prefix}/var/varnish"
     34       
     35        move ${destroot}${prefix}/etc/varnish/default.vcl ${destroot}${prefix}/etc/varnish/default.vcl.default
     36    if {![file exists ${prefix}/etc/varnish/default.vcl]} {
     37                xinstall -m 755 -d "${prefix}/etc/varnish"
     38                xinstall -m 644 ${destroot}${prefix}/etc/varnish/default.vcl.default ${prefix}/etc/varnish/default.vcl
     39                notes-append "Please, configure the ${prefix}/etc/varnish/default.vcl before start the service."
     40        }
     41       
     42        xinstall -m 755 "${filespath}/varnish-server.in" "${destroot}${prefix}/sbin/varnish-server"
     43        xinstall -m 755 "${filespath}/varnish-vcl-reload.in" "${destroot}${prefix}/bin/varnish-vcl-reload"
     44        xinstall -m 644 "${filespath}/varnish-server.conf.in" "${destroot}${prefix}/etc/varnish/varnish-server.conf.default"
     45       
     46    reinplace "s|@PREFIX@|${prefix}|g" "${destroot}${prefix}/sbin/varnish-server"
     47    reinplace "s|@PREFIX@|${prefix}|g" "${destroot}${prefix}/bin/varnish-vcl-reload"
     48    reinplace "s|@PREFIX@|${prefix}|g" "${destroot}${prefix}/etc/varnish/varnish-server.conf.default"
     49       
     50    if {![file exists ${prefix}/etc/varnish/varnish-server.conf]} {
     51                xinstall -m 755 -d "${prefix}/etc/varnish"
     52                xinstall -m 644 "${destroot}${prefix}/etc/varnish/varnish-server.conf.default" "${prefix}/etc/varnish/varnish-server.conf"
     53                notes-append "The file ${prefix}/etc/varnish/varnish-server.conf is used by ${prefix}/sbin/varnish-server."
     54        }
     55}
     56
     57livecheck.url                   ${master_sites}
     58livecheck.type                  regex
     59livecheck.regex                 varnish-(\\d+\\.\\d+\\.\\d+).tar.gz
  • files/varnish-server.conf.in

     
     1# Command line options to varnishd
     2# based on https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/varnish
     3
     4
     5VARNISH_CFG="@PREFIX@/etc/varnish/default.vcl"
     6
     7VARNISH_PID="@PREFIX@/var/run/varnishd.pid"
     8
     9VARNISHD_OPTS="-a 0.0.0.0:80 \
     10               -f $VARNISH_CFG \
     11               -T localhost:6082 \
     12                           -P $VARNISH_PID \
     13               -s malloc,64M
     14               -u nobody -g nobody"
  • files/varnish-server.in

     
     1#!/bin/bash
     2
     3. @PREFIX@/etc/varnish/varnish-server.conf
     4
     5case $1 in
     6  start)
     7    if /opt/local/sbin/varnishd $VARNISHD_OPTS; then
     8          exit 0
     9    else
     10      echo "Varnish start FAIL"
     11      exit 1
     12    fi
     13    ;;
     14  stop)
     15    if [[ $PID ]] && kill $PID &>/dev/null; then
     16      exit 0
     17    else
     18      exit 1
     19    fi
     20    ;;
     21  restart)
     22    $0 stop
     23    sleep 1
     24    $0 start
     25    ;;
     26  reload)
     27    status "Recompiling and Reloading VCL" varnish-vcl-reload $VARNISH_CFG
     28    ;;
     29  *)
     30    echo "usage: $0 {start|stop|restart|reload}"
     31  ;;
     32esac
  • files/varnish-vcl-reload.in

    Property changes on: files/varnish-server.in
    ___________________________________________________________________
    Added: svn:executable
    ## -0,0 +1 ##
    +*
    \ No newline at end of property
     
     1#!/bin/sh
     2# based on https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/varnish
     3
     4cfg=${1:-@PREFIX@/etc/varnish/default.vcl}
     5if [ ! -e "$cfg" ]; then
     6  printf 'ERROR: VCL file %s does not exist\n' "$cfg" >&2
     7  exit 1
     8fi
     9
     10activecfg=$(varnishadm 'vcl.list' | awk '/active/ { print $3 }')
     11if [ -z "$activecfg" ]; then
     12  printf 'ERROR: No active VCL found!\n' >&2
     13  exit 1
     14fi
     15
     16newcfg=$(date +'vcl-%s')
     17printf 'INFO: using new config %s\n' "$cfg"
     18
     19varnishadm "vcl.load $newcfg $cfg" &&
     20varnishadm "vcl.use $newcfg" &&
     21varnishadm "vcl.discard $activecfg"