Ticket #35863: 20121231-varnish-startup.patch

File 20121231-varnish-startup.patch, 5.2 KB (added by robsonpeixoto@…, 12 years ago)

Full Solution. Creating all files and directories that I forgotten on last patch.

  • Portfile

     
    11# $Id$
    22
    3 PortSystem            1.0
     3PortSystem          1.0
    44
    5 name                  varnish
    6 epoch                 20110709
    7 version               3.0.3
    8 categories            www
    9 platforms             darwin
    10 maintainers           pmq openmaintainer
     5name                varnish
     6epoch               20110709
     7version             3.0.3
     8revision            1
     9categories          www
     10platforms           darwin
     11maintainers         pmq openmaintainer
    1112
    12 description           Varnish is a state-of-the-art, high-performance HTTP accelerator
    13 long_description      Varnish was written from the ground up to be a high \
    14                       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.
    1516
    16 homepage              http://www.varnish-cache.org
    17 master_sites          http://repo.varnish-cache.org/source/
     17homepage            http://www.varnish-cache.org
     18master_sites       http://repo.varnish-cache.org/source/
    1819
    19 checksums             rmd160 a911a2637ef26607aad8a1c34a83bc797a15235d \
    20                       sha256 2d37d18d952f58b208ac3a0706d4d3e4c0de304b1fcc9df5019571c75f148ab2
     20checksums           rmd160 a911a2637ef26607aad8a1c34a83bc797a15235d \
     21                    sha256 2d37d18d952f58b208ac3a0706d4d3e4c0de304b1fcc9df5019571c75f148ab2
    2122
    22 depends_build         port:pkgconfig
     23depends_build       port:pkgconfig
    2324
    24 depends_lib           port:pcre
     25depends_lib         port:pcre
     26
     27startupitem.create  yes
     28startupitem.start   "${prefix}/share/${name}/varnish.init start"
     29startupitem.stop    "${prefix}/share/${name}/varnish.init stop"
     30
     31post-destroot {
     32  # create dir
     33  xinstall -d -m 755 ${destroot}${prefix}/share/${name}
     34
     35  # copy files
     36  xinstall -m 644 ${filespath}/varnish.conf.in ${destroot}${prefix}/etc/${name}/varnish.conf.default
     37  xinstall -m 755 ${filespath}/varnish.init.in ${destroot}${prefix}/share/${name}/${name}.init
     38  xinstall -m 755 ${filespath}/varnish-vcl-reload.in ${destroot}${prefix}/sbin/varnish-vcl-reload
     39
     40  # replace @PREFIX@ to ${prefix}
     41  reinplace "s|@PREFIX@|${prefix}|g" \
     42    ${destroot}${prefix}/etc/${name}/varnish.conf.default \
     43    ${destroot}${prefix}/share/${name}/${name}.init \
     44    ${destroot}${prefix}/sbin/varnish-vcl-reload
     45
     46  file rename ${destroot}${prefix}/etc/${name}/default.vcl ${destroot}${prefix}/etc/${name}/default.vcl.default
     47}
     48
     49post-activate {
     50  if {![file exists ${prefix}/etc/${name}/default.vcl]} {
     51    file copy ${prefix}/etc/${name}/default.vcl.default \
     52      ${prefix}/etc/${name}/default.vcl
     53  }
     54  if {![file exists ${prefix}/etc/${name}/varnish.conf]} {
     55    file copy ${prefix}/etc/${name}/varnish.conf.default \
     56      ${prefix}/etc/${name}/varnish.conf
     57  }
     58
     59  # dirs nedded to run varnish
     60  xinstall -d -m 755 -o nobody -g nobody ${prefix}/var/${name}
     61  xinstall -d -m 755 -o nobody -g nobody ${prefix}/var/run/${name}
     62}
     63
     64livecheck.url       ${master_sites}
     65livecheck.type      regex
     66livecheck.regex     ${name}-(\\d+\\.\\d+\\.\\d+).tar.gz
  • files/varnish-vcl-reload.in

     
     1#!/bin/sh
     2
     3cfg=${1:-@PREFIX@/etc/varnish/default.vcl}
     4if [ ! -e "$cfg" ]; then
     5  printf 'ERROR: VCL file %s does not exist\n' "$cfg" >&2
     6  exit 1
     7fi
     8
     9activecfg=$(varnishadm 'vcl.list' | awk '/active/ { print $3 }')
     10if [ -z "$activecfg" ]; then
     11  printf 'ERROR: No active VCL found!\n' >&2
     12  exit 1
     13fi
     14
     15newcfg=$(date +'vcl-%s')
     16printf 'INFO: using new config %s\n' "$cfg"
     17
     18varnishadm "vcl.load $newcfg $cfg" &&
     19varnishadm "vcl.use $newcfg" &&
     20varnishadm "vcl.discard $activecfg"
  • files/varnish.conf.in

     
     1#
     2# MANDATORIES command line options to varnishd
     3#
     4
     5VARNISH_CFG="@PREFIX@/etc/varnish/default.vcl"
     6VARNISHD_PID="@PREFIX@/var/run/varnish/varnish.pid"
     7
     8VARNISHD_OPTS="-a 0.0.0.0:80 \
     9               -f $VARNISH_CFG \
     10               -T localhost:6082 \
     11               -P $VARNISHD_PID \
     12               -s malloc,64M
     13               -u nobody -g nobody"
  • files/varnish.init.in

     
     1#!/bin/bash
     2
     3. @PREFIX@/etc/varnish/varnish.conf
     4
     5if [[ -r $VARNISHD_PID ]]; then
     6  read -r PID < "$VARNISHD_PID"
     7  ps -p $PID &> /dev/null
     8  CHECK=$?
     9  if [[ "x$CHECK" == "x1" ]]; then
     10    unset PID
     11    rm -f "$VARNISHD_PID"
     12  fi
     13fi
     14
     15case $1 in
     16  start)
     17    @PREFIX@/sbin/varnishd $VARNISHD_OPTS
     18    ;;
     19  stop)
     20    [[ $PID ]] && kill $PID &>/dev/null
     21    ;;
     22  restart)
     23    $0 stop
     24    sleep 1
     25    $0 start
     26    ;;
     27  reload)
     28    @PREFIX@/sbin/varnish-vcl-reload $VARNISH_CFG
     29    ;;
     30  *)
     31    echo "usage: $0 {start|stop|restart|reload}"
     32    ;;
     33esac