Commit 7d416c2a authored by Lasse Karstensen's avatar Lasse Karstensen

Import files from pkg-redhat.

As they were on 312aff61f125456f0989e7643bc87fea37ab44be .
parent f6cebc53
#!/bin/bash
# This script is used to inject the Varnish ABI into the RPM Provides.
set -o errexit
if [ -x /usr/lib/rpm/redhat/find-provides ]; then
/usr/lib/rpm/redhat/find-provides "$@"
elif [ -x /usr/lib/rpm/find-provides ]; then
/usr/lib/rpm/find-provides "$@"
fi
# We don't install vcs_version.h, so we can't use RPM_BUILD_ROOT directly.
cd /builddir/build/BUILD/varnish* || true
cd ${RPM_BUILD_ROOT}/../../BUILD/varnish* || true
printf '#include "vcs_version.h"\nVCS_Version\n' \
| cpp - -Iinclude | sed -e '/^"/!d' -e 's/\"//g' -e 's/^/varnishabi-strict-/'
printf '#include "vrt.h"\nvarnishabi- VRT_MAJOR_VERSION . VRT_MINOR_VERSION\n' \
| cpp - -Iinclude \
| sed -e '/^varnishabi-/!d' -e 's/U//g' -e 's/ //g'
#!/bin/sh
#
# Init script for Varnish Cache.
#
# chkconfig: - 90 10
# description: Varnish is a high-performance HTTP accelerator
# processname: varnishd
# config: /etc/sysconfig/varnish
# pidfile: /var/run/varnish.pid
### BEGIN INIT INFO
# Provides: varnish
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start:
# Default-Stop:
# Should-Start: $syslog
# Short-Description: start and stop varnishd
# Description: Varnish is a high-performance HTTP accelerator
### END INIT INFO
# Source function library.
. /etc/init.d/functions
retval=0
pidfile=/var/run/varnish.pid
exec="/usr/sbin/varnishd"
reload_exec="/usr/sbin/varnish_reload_vcl"
prog="varnishd"
config="/etc/sysconfig/varnish"
lockfile="/var/lock/subsys/varnish"
# Include varnish defaults
[ -e /etc/sysconfig/varnish ] && . /etc/sysconfig/varnish
start() {
if [ ! -x $exec ]
then
echo $exec not found
exit 5
fi
if [ ! -f $config ]
then
echo $config not found
exit 6
fi
echo -n "Starting Varnish Cache: "
# Open files (usually 1024, which is way too small for varnish)
ulimit -n ${NFILES:-131072}
# Varnish wants to lock shared memory log in memory.
ulimit -l ${MEMLOCK:-82000}
# Maximum number of threads (default in CentOS is 1024, which
# is often too small for varnish)
ulimit -u ${NPROCS:-unlimited}
# If defined, set maximum core size.
if [ -n "${DAEMON_COREFILE_LIMIT}" ]
then
ulimit -c ${DAEMON_COREFILE_LIMIT}
fi
# $DAEMON_OPTS is set in /etc/sysconfig/varnish.
if [ "$DAEMON_OPTS" = "" ]; then
echo "\$DAEMON_OPTS is empty."
echo -n "Please put configuration options in $config"
return 6
else
daemon --pidfile $pidfile $exec "$DAEMON_OPTS" -P $pidfile
retval=$?
if [ $retval -eq 0 ]
then
touch $lockfile
echo_success
echo
else
echo_failure
echo
fi
return $retval
fi
}
stop() {
echo -n "Stopping Varnish Cache: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
if [ "$RELOAD_VCL" = "1" ]
then
$reload_exec
else
force_reload
fi
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
configtest() {
if [ -f "$VARNISH_VCL_CONF" ]; then
$exec -C $DAEMON_OPTS -n /tmp 2>/dev/null
if [ "$?" = 0 ]; then
echo "Syntax ok"
else
$exec -C $DAEMON_OPTS -n /tmp
return $?
fi
else
echo "VARNISH_VCL_CONF is unset or does not point to a file."
fi
}
# See how we were called.
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
configtest)
configtest
;;
*)
echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
/var/log/varnish/varnish.log /var/log/varnish/varnishncsa.log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/bin/kill -HUP `cat /var/run/varnishlog.pid 2>/dev/null` 2> /dev/null || true
/bin/kill -HUP `cat /var/run/varnishncsa.pid 2>/dev/null` 2> /dev/null || true
endscript
}
# Varnish environment configuration description. This was derived from
# the old style sysconfig/defaults settings
# Set this to 1 to make systemd reload try to switch VCL without restart.
RELOAD_VCL=1
# Main configuration file. You probably want to change it.
VARNISH_VCL_CONF=/etc/varnish/default.vcl
# Default address and port to bind to. Blank address means all IPv4
# and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted
# quad, or an IPv6 address in brackets.
# VARNISH_LISTEN_ADDRESS=192.168.1.5
VARNISH_LISTEN_PORT=6081
# Admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
# Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret
# Backend storage specification, see Storage Types in the varnishd(5)
# man page for details.
VARNISH_STORAGE="malloc,256M"
# User and group for the varnishd worker processes
VARNISH_USER=varnish
VARNISH_GROUP=varnish
# Other options, see the man page varnishd(1)
#DAEMON_OPTS="-p thread_pool_min=5 -p thread_pool_max=500 -p thread_pool_timeout=300"
[Unit]
Description=Varnish Cache, a high-performance HTTP accelerator
After=syslog.target network.target
[Service]
# If you want to make changes to this file, please copy it to
# /etc/systemd/system/varnish.service and make your changes there.
# This will override the file kept at /lib/systemd/system/varnish.service
#
# Enviroment variables may be found in /etc/varnish/varnish.params
#
# Maximum number of open files (for ulimit -n)
LimitNOFILE=131072
# Locked shared memory (for ulimit -l)
# Default log size is 82MB + header
LimitMEMLOCK=82000
# Maximum size of the corefile.
LimitCORE=infinity
EnvironmentFile=/etc/varnish/varnish.params
Type=forking
PIDFile=/var/run/varnish.pid
PrivateTmp=true
ExecStartPre=/usr/sbin/varnishd -C -f $VARNISH_VCL_CONF $DAEMON_OPTS
ExecStart=/usr/sbin/varnishd \
-P /var/run/varnish.pid \
-f $VARNISH_VCL_CONF \
-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-S $VARNISH_SECRET_FILE \
-s $VARNISH_STORAGE \
$DAEMON_OPTS
ExecReload=/usr/sbin/varnish_reload_vcl
[Install]
WantedBy=multi-user.target
%define XXv_rc beta1
%define vd_rc %{?v_rc:-%{?v_rc}}
%define _use_internal_dependency_generator 0
%define __find_provides %{_builddir}/../SOURCES/find-provides
Summary: High-performance HTTP accelerator
Name: varnish
Version: 4.1.0
#Release: 0.20140328%{?v_rc}%{?dist}
Release: %{?v_rc}%{?dist}
License: BSD
Group: System Environment/Daemons
URL: https://www.varnish-cache.org/
#Source0: http://repo.varnish-cache.org/source/%{name}-%{version}.tar.gz
Source0: %{name}-%{version}%{?vd_rc}.tar.gz
#Source0: %{name}-trunk.tar.gz
Source1: varnish.initrc
Source2: varnish.sysconfig
Source3: varnish.logrotate
Source4: varnish_reload_vcl
Source5: varnish.params
Source6: varnish.service
Source7: varnishlog.initrc
Source8: varnishlog.service
Source9: varnishncsa.initrc
Source10: varnishncsa.service
Source11: find-provides
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: automake
BuildRequires: autoconf
BuildRequires: jemalloc-devel
BuildRequires: libedit-devel
BuildRequires: libtool
BuildRequires: ncurses-devel
BuildRequires: pcre-devel
BuildRequires: pkgconfig
BuildRequires: python-docutils >= 0.6
BuildRequires: python-sphinx
Requires: jemalloc
Requires: libedit
Requires: logrotate
Requires: ncurses
Requires: pcre
Requires: varnish-libs = %{version}-%{release}
Requires(pre): shadow-utils
Requires(post): /sbin/chkconfig, /usr/bin/uuidgen
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
%if %{undefined suse_version}
Requires(preun): initscripts
%endif
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
Requires(post): systemd-units
Requires(post): systemd-sysv
Requires(preun): systemd-units
Requires(postun): systemd-units
BuildRequires: systemd-units
%endif
Requires: gcc
%description
This is Varnish Cache, a high-performance HTTP accelerator.
Varnish Cache stores web pages in memory so web servers don't have to
create the same web page over and over again. Varnish Cache serves
pages much faster than any application server; giving the website a
significant speed up.
Documentation wiki and additional information about Varnish Cache is
available on the following web site: https://www.varnish-cache.org/
%package libs
Summary: Libraries for %{name}
Group: System Environment/Libraries
BuildRequires: ncurses-devel
%description libs
Libraries for %{name}.
Varnish Cache is a high-performance HTTP accelerator
%package libs-devel
Summary: Development files for %{name}-libs
Group: System Environment/Libraries
BuildRequires: ncurses-devel
Requires: varnish-libs = %{version}-%{release}
Requires: python
%description libs-devel
Development files for %{name}-libs
Varnish Cache is a high-performance HTTP accelerator
%package docs
Summary: Documentation files for %name
Group: System Environment/Libraries
%description docs
Documentation files for %name
%prep
%setup -n varnish-%{version}%{?vd_rc}
#%setup -q -n varnish-trunk
cp %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} .
cp %{SOURCE6} %{SOURCE7} %{SOURCE8} %{SOURCE9} %{SOURCE10} %{SOURCE11} .
%build
# No pkgconfig/libpcre.pc in rhel4
%if 0%{?rhel} == 4
export PCRE_CFLAGS="`pcre-config --cflags`"
export PCRE_LIBS="`pcre-config --libs`"
%endif
%if 0%{?rhel} == 6
export CFLAGS="$CFLAGS -O2 -g -Wp,-D_FORTIFY_SOURCE=0"
%endif
# Remove "--disable static" if you want to build static libraries
# jemalloc is not compatible with Red Hat's ppc64 RHEL kernel :-(
%ifarch ppc64 ppc
%configure --disable-static --localstatedir=/var/lib --without-jemalloc --without-rst2html
%else
%configure --disable-static --localstatedir=/var/lib --without-rst2html
%endif
# We have to remove rpath - not allowed in Fedora
# (This problem only visible on 64 bit arches)
#sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g;
# s|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
make %{?_smp_mflags} V=1
%if 0%{?fedora}%{?rhel} != 0 && 0%{?rhel} <= 4 && 0%{?fedora} <= 8
# Old style daemon function
sed -i 's,--pidfile \$pidfile,,g;
s,status -p \$pidfile,status,g;
s,killproc -p \$pidfile,killproc,g' \
varnish.initrc varnishlog.initrc varnishncsa.initrc
%endif
rm -rf doc/html/_sources
#rm -rf doc/sphinx/build/html/_sources
#mv doc/sphinx/build/html doc
rm -rf doc/sphinx/build
%check
# rhel5 on ppc64 is just too strange
%ifarch ppc64
%if 0%{?rhel} > 4
cp bin/varnishd/.libs/varnishd bin/varnishd/lt-varnishd
%endif
%endif
# The redhat ppc builders seem to have some ulimit problems?
# These tests work on a rhel4 ppc/ppc64 instance outside the builders
%ifarch ppc64 ppc
%if 0%{?rhel} == 4
rm bin/varnishtest/tests/c00031.vtc
rm bin/varnishtest/tests/r00387.vtc
%endif
%endif
make check %{?_smp_mflags} LD_LIBRARY_PATH="../../lib/libvarnish/.libs:../../lib/libvarnishcompat/.libs:../../lib/libvarnishapi/.libs:../../lib/libvcc/.libs:../../lib/libvgz/.libs" VERBOSE=1
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot} INSTALL="install -p"
# None of these for fedora
find %{buildroot}/%{_libdir}/ -name '*.la' -exec rm -f {} ';'
# Remove this line to build a devel package with symlinks
#find %{buildroot}/%{_libdir}/ -name '*.so' -type l -exec rm -f {} ';'
mkdir -p %{buildroot}/var/lib/varnish
mkdir -p %{buildroot}/var/log/varnish
mkdir -p %{buildroot}/var/run/varnish
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d/
install -D -m 0644 etc/example.vcl %{buildroot}%{_sysconfdir}/varnish/default.vcl
install -D -m 0644 varnish.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/varnish
# systemd support
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
mkdir -p %{buildroot}%{_unitdir}
install -D -m 0644 varnish.service %{buildroot}%{_unitdir}/varnish.service
install -D -m 0644 varnish.params %{buildroot}%{_sysconfdir}/varnish/varnish.params
install -D -m 0644 varnishncsa.service %{buildroot}%{_unitdir}/varnishncsa.service
install -D -m 0644 varnishlog.service %{buildroot}%{_unitdir}/varnishlog.service
sed -i 's,sysconfig/varnish,varnish/varnish.params,' varnish_reload_vcl
# default is standard sysvinit
%else
install -D -m 0644 varnish.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/varnish
install -D -m 0755 varnish.initrc %{buildroot}%{_initrddir}/varnish
install -D -m 0755 varnishlog.initrc %{buildroot}%{_initrddir}/varnishlog
install -D -m 0755 varnishncsa.initrc %{buildroot}%{_initrddir}/varnishncsa
%endif
install -D -m 0755 varnish_reload_vcl %{buildroot}%{_sbindir}/varnish_reload_vcl
echo %{_libdir}/varnish > %{buildroot}%{_sysconfdir}/ld.so.conf.d/varnish-%{_arch}.conf
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_sbindir}/*
%{_bindir}/*
%{_var}/lib/varnish
%{_var}/log/varnish
%{_mandir}/man1/*.1*
%{_mandir}/man3/*.3*
%{_mandir}/man7/*.7*
%doc LICENSE README
%{_docdir}/varnish/
%dir %{_sysconfdir}/varnish/
%config(noreplace) %{_sysconfdir}/varnish/default.vcl
%config(noreplace) %{_sysconfdir}/logrotate.d/varnish
# systemd from fedora 17 and rhel 7
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
%{_unitdir}/varnish.service
%{_unitdir}/varnishncsa.service
%{_unitdir}/varnishlog.service
%config(noreplace)%{_sysconfdir}/varnish/varnish.params
# default is standard sysvinit
%else
%config(noreplace) %{_sysconfdir}/sysconfig/varnish
%{_initrddir}/varnish
%{_initrddir}/varnishlog
%{_initrddir}/varnishncsa
%endif
%files libs
%defattr(-,root,root,-)
%{_libdir}/*.so.*
%{_libdir}/varnish
%doc LICENSE
%config %{_sysconfdir}/ld.so.conf.d/varnish-%{_arch}.conf
%files libs-devel
%defattr(-,root,root,-)
%{_libdir}/lib*.so
%dir %{_includedir}/varnish
%{_includedir}/varnish/*
%{_libdir}/pkgconfig/varnishapi.pc
/usr/share/varnish
/usr/share/aclocal
%doc LICENSE
%files docs
%defattr(-,root,root,-)
%doc LICENSE
%doc doc/html
%doc doc/changes*.html
%pre
getent group varnish >/dev/null || groupadd -r varnish
getent passwd varnish >/dev/null || \
useradd -r -g varnish -d /var/lib/varnish -s /sbin/nologin \
-c "Varnish Cache" varnish
exit 0
%post
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%else
/sbin/chkconfig --add varnish
/sbin/chkconfig --add varnishlog
/sbin/chkconfig --add varnishncsa
%endif
test -f /etc/varnish/secret || (uuidgen > /etc/varnish/secret && chmod 0600 /etc/varnish/secret)
%triggerun -- varnish < 3.0.2-1
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply varnish
# to migrate them to systemd targets
%{_bindir}/systemd-sysv-convert --save varnish >/dev/null 2>&1 ||:
# If the package is allowed to autostart:
#/bin/systemctl --no-reload enable varnish.service >/dev/null 2>&1 ||:
# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del varnish >/dev/null 2>&1 || :
#/bin/systemctl try-restart varnish.service >/dev/null 2>&1 || :
%preun
if [ $1 -lt 1 ]; then
# Package removal, not upgrade
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
/bin/systemctl --no-reload disable varnish.service > /dev/null 2>&1 || :
/bin/systemctl stop varnish.service > /dev/null 2>&1 || :
%else
/sbin/service varnish stop > /dev/null 2>&1
/sbin/service varnishlog stop > /dev/null 2>&1
/sbin/service varnishncsa stop > /dev/null 2>%1
/sbin/chkconfig --del varnish
/sbin/chkconfig --del varnishlog
/sbin/chkconfig --del varnishncsa
%endif
fi
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
%changelog
* Fri Sep 22 2006 Ingvar Hagelund <ingvar@linpro.no> - 1.0.1-1
- Initial build.
# Configuration file for Varnish Cache
#
# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
# shell script fragment.
#
# Maximum number of open files (for ulimit -n)
NFILES=131072
# Locked shared memory (for ulimit -l)
# Default log size is 82MB + header
MEMLOCK=82000
# Maximum number of threads (for ulimit -u)
NPROCS="unlimited"
# Maximum size of corefile (for ulimit -c). Default in Fedora is 0
# DAEMON_COREFILE_LIMIT="unlimited"
# Init script support to reload/switch vcl without restart.
# To make this work, you need to set the following variables
# explicit: VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_ADDRESS,
# VARNISH_ADMIN_LISTEN_PORT, VARNISH_SECRET_FILE.
RELOAD_VCL=1
# Main configuration file.
VARNISH_VCL_CONF=/etc/varnish/default.vcl
#
# Default address and port to bind to
# Blank address means all IPv4 and IPv6 interfaces, otherwise specify
# a host name, an IPv4 dotted quad, or an IPv6 address in brackets.
VARNISH_LISTEN_PORT=6081
#
# Telnet admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
#
# Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret
#
# The minimum number of worker threads to start
VARNISH_MIN_THREADS=50
#
# The Maximum number of worker threads to start
VARNISH_MAX_THREADS=1000
#
# Cache file size: in bytes, optionally using k / M / G / T suffix.
VARNISH_STORAGE_SIZE=256M
#
# Backend storage specification
VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
#
# Default TTL used when the backend does not specify one
VARNISH_TTL=120
#
# DAEMON_OPTS is used by the init script.
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-f ${VARNISH_VCL_CONF} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-p thread_pool_min=${VARNISH_MIN_THREADS} \
-p thread_pool_max=${VARNISH_MAX_THREADS} \
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE}"
#!/bin/bash
#
# reload vcl revisited
# A script that loads new vcl based on data from /etc/sysconfig/varnish
# Ingvar Hagelund <ingvar@redpill-linpro.com>
#
# This is free software, distributed under the standard 2 clause BSD license,
# see the LICENSE file in the Varnish documentation directory
#
# The following environment variables have to be set:
# RELOAD_VCL, VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_PORT
# The following are optional:
# VARNISH_SECRET_FILE, VARNISH_ADMIN_LISTEN_ADDRESS
#
# Requires GNU bash and GNU date
#
debug=false
missing() {
echo "Missing configuration variable: $1"
exit 2
}
print_debug() {
echo "
Parsed configuration:
RELOAD_VCL=\"$RELOAD_VCL\"
VARNISH_VCL_CONF=\"$VARNISH_VCL_CONF\"
VARNISH_ADMIN_LISTEN_ADDRESS=\"$VARNISH_ADMIN_LISTEN_ADDRESS\"
VARNISH_ADMIN_LISTEN_PORT=\"$VARNISH_ADMIN_LISTEN_PORT\"
VARNISH_SECRET_FILE=\"$VARNISH_SECRET_FILE\"
"
}
# Fallback to the default configuration
if [ -z "$VARNISH_VCL_CONF" ]; then
. /etc/sysconfig/varnish
fi
$debug && print_debug
# Check configuration
if [ ! "$RELOAD_VCL" = "1" ]; then
echo "Error: RELOAD_VCL is not set to 1"
exit 2
elif [ -z "$VARNISH_VCL_CONF" ]; then
echo "Error: VARNISH_VCL_CONF is not set"
exit 2
elif [ ! -s "$VARNISH_VCL_CONF" ]; then
echo "Eror: VCL config $VARNISH_VCL_CONF is unreadable or empty"
exit 2
elif [ -z "$VARNISH_ADMIN_LISTEN_ADDRESS" ]; then
echo "Warning: VARNISH_ADMIN_LISTEN_ADDRESS is not set, using 127.0.0.1"
VARNISH_ADMIN_LISTEN_ADDRESS="127.0.0.1"
elif [ -z "$VARNISH_ADMIN_LISTEN_PORT" ]; then
echo "Error: VARNISH_ADMIN_LISTEN_PORT is not set"
exit 2
elif [ -z "$VARNISH_SECRET_FILE" ]; then
echo "Warning: VARNISH_SECRET_FILE is not set"
secret=""
elif [ ! -s "$VARNISH_SECRET_FILE" ]; then
echo "Error: varnish secret file $VARNISH_SECRET_FILE is unreadable or empty"
exit 2
else
secret="-S $VARNISH_SECRET_FILE"
fi
# Done parsing, set up command
VARNISHADM="varnishadm $secret -T $VARNISH_ADMIN_LISTEN_ADDRESS:$VARNISH_ADMIN_LISTEN_PORT"
# Now do the real work
new_config="reload_$(date +%FT%H:%M:%S)"
# Check if we are able to connect at all
if $VARNISHADM vcl.list > /dev/null; then
$debug && echo vcl.list succeeded
else
echo "Unable to run $VARNISHADM vcl.list"
exit 1
fi
if $VARNISHADM vcl.list | awk ' { print $3 } ' | grep -q $new_config; then
echo Trying to use new config $new_config, but that is already in use
exit 2
fi
current_config=$( $VARNISHADM vcl.list | awk ' /^active/ { print $3 } ' )
echo "Loading vcl from $VARNISH_VCL_CONF"
echo "Current running config name is $current_config"
echo "Using new config name $new_config"
if $VARNISHADM vcl.load $new_config $VARNISH_VCL_CONF; then
$debug && echo "$VARNISHADM vcl.load succeded"
else
echo "$VARNISHADM vcl.load failed"
exit 1
fi
if $VARNISHADM vcl.use $new_config; then
$debug && echo "$VARNISHADM vcl.use succeded"
else
echo "$VARNISHADM vcl.use failed"
exit 1
fi
$VARNISHADM vcl.list
echo Done
exit 0
#! /bin/sh
#
# Control the Varnish Cache raw logging daemon
#
# chkconfig: - 90 10
# description: Varnish Cache raw logging daemon
# processname: varnishlog
# config:
# pidfile: /var/run/varnishlog.pid
### BEGIN INIT INFO
# Provides: varnishlog
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start:
# Default-Stop:
# Short-Description: start and stop varnishlog
# Description: Varnish Cache raw logging daemon
### END INIT INFO
# Source function library.
. /etc/init.d/functions
retval=0
pidfile="/var/run/varnishlog.pid"
lockfile="/var/lock/subsys/varnishlog"
logfile="/var/log/varnish/varnish.log"
exec="/usr/bin/varnishlog"
prog="varnishlog"
DAEMON_OPTS="-a -w $logfile -D -P $pidfile"
# Include varnishlog defaults
[ -e /etc/sysconfig/varnishlog ] && . /etc/sysconfig/varnishlog
start() {
if [ ! -x $exec ]
then
echo $exec not found
exit 5
fi
echo -n "Starting varnish logging daemon: "
daemon --pidfile $pidfile $exec "$DAEMON_OPTS"
echo
return $retval
}
stop() {
echo -n "Stopping varnish logging daemon: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
# See how we were called.
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
[Unit]
Description=Varnish Cache HTTP accelerator logging daemon
After=varnish.service
[Service]
Type=forking
PIDFile=/run/varnishlog.pid
ExecStart=/usr/bin/varnishlog -a -w /var/log/varnish/varnish.log -D -P /run/varnishlog.pid
[Install]
WantedBy=multi-user.target
#! /bin/sh
#
# Control the Varnish Cache NCSA logging daemon
#
# chkconfig: - 90 10
# description: Varnish Cache logging daemon
# processname: varnishncsa
# config:
# pidfile: /var/run/varnishncsa.pid
### BEGIN INIT INFO
# Provides: varnishncsa
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start:
# Default-Stop:
# Short-Description: start and stop varnishncsa
# Description: Varnish Cache NCSA logging daemon
### END INIT INFO
# Source function library.
. /etc/init.d/functions
retval=0
pidfile="/var/run/varnishncsa.pid"
lockfile="/var/lock/subsys/varnishncsa"
logfile="/var/log/varnish/varnishncsa.log"
exec="/usr/bin/varnishncsa"
prog="varnishncsa"
DAEMON_OPTS="-a -w $logfile -D -P $pidfile"
# Include varnishncsa defaults
[ -e /etc/sysconfig/varnishncsa ] && . /etc/sysconfig/varnishncsa
start() {
if [ ! -x $exec ]
then
echo $exec not found
exit 5
fi
echo -n "Starting varnish ncsa logging daemon: "
daemon --pidfile $pidfile $exec "$DAEMON_OPTS"
echo
return $retval
}
stop() {
echo -n "Stopping varnish ncsa logging daemon: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
# See how we were called.
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
[Unit]
Description=Varnish Cache HTTP accelerator NCSA daemon
After=varnish.service
[Service]
Type=forking
PIDFile=/run/varnishncsa.pid
ExecStart=/usr/bin/varnishncsa -a -w /var/log/varnish/varnishncsa.log -D -P /run/varnishncsa.pid
[Install]
WantedBy=multi-user.target
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment