Commit aee37a01 authored by Denis Brækhus's avatar Denis Brækhus

Keep a copy of the sysv files in the repo.

As per discussion, to better facilitate alternate init-
systems and re-packaging efforts, we want to keep in the
sysv versions of the packaging files.
parent aa9a561a
# Configuration file for Varnish Cache.
#
# /etc/init.d/varnish expects the variables $DAEMON_OPTS, $NFILES and $MEMLOCK
# to be set from this shell script fragment.
#
# Note: If systemd is installed, this file is obsolete and ignored. You will
# need to copy /lib/systemd/system/varnish.service to /etc/systemd/system/ and
# edit that file.
# Should we start varnishd at boot? Set to "no" to disable.
START=yes
# Maximum number of open files (for ulimit -n)
NFILES=131072
# Maximum locked memory size (for ulimit -l)
# Used for locking the shared memory log in memory. If you increase log size,
# you need to increase this number as well
MEMLOCK=82000
DAEMON_OPTS="-a :6081 \
-f /etc/varnish/default.vcl \
-s malloc,256m"
#! /bin/sh
### BEGIN INIT INFO
# Provides: varnish
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start HTTP accelerator
# Description: This script provides a server-side cache
# to be run in front of a httpd and should
# listen on port 80 on a properly configured
# system
### END INIT INFO
# Source function library
. /lib/lsb/init-functions
SERVICE=varnishd
DESC="HTTP accelerator"
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/varnishd
PIDFILE=/run/$SERVICE.pid
test -x $DAEMON || { echo "${DAEMON} has no execute bit"; exit 0; }
# Include varnish defaults if available
if [ -f /etc/default/varnish ] ; then
. /etc/default/varnish
fi
# Open files (usually 1024, which is way too small for varnish)
ulimit -n ${NFILES:-131072}
# Maxiumum locked memory size for shared memory log
ulimit -l ${MEMLOCK:-82000}
# If $DAEMON_OPTS is not set at all in /etc/default/varnish, use minimal useful
# defaults (Backend at localhost:8080, a common place to put a locally
# installed application server.)
DAEMON_OPTS=${DAEMON_OPTS:--b localhost}
# Ensure we have a PATH
export PATH="${PATH:+$PATH:}/usr/sbin:/usr/bin:/sbin:/bin"
start_varnishd() {
log_daemon_msg "Starting $DESC" "$SERVICE"
output=$(/bin/tempfile -s.varnish)
if start-stop-daemon \
--start --pidfile ${PIDFILE} --exec ${DAEMON} -- \
${DAEMON_OPTS} -P ${PIDFILE} > ${output} 2>&1; then
log_end_msg 0
else
log_end_msg 1
cat $output
exit 1
fi
rm $output
}
disabled_varnishd() {
log_daemon_msg "Not starting $DESC" "$SERVICE"
log_progress_msg "disabled in /etc/default/varnish"
log_end_msg 0
}
stop_varnishd() {
log_daemon_msg "Stopping $DESC" "$SERVICE"
if start-stop-daemon \
--stop --pidfile $PIDFILE --retry 10 \
--exec $DAEMON; then
log_end_msg 0
else
log_end_msg 1
fi
if test -r $PIDFILE; then
read -r PID < $PIDFILE
if test ! -d /proc/$PID ; then
# stale pidfile
unset PID
rm -f $PIDFILE
fi
fi
}
reload_varnishd() {
log_daemon_msg "Reloading $DESC" "$SERVICE"
# Workaround for the reload script to make it work with instances
export DAEMON_OPTS
if /usr/sbin/varnishreload; then
log_end_msg 0
else
log_end_msg 1
fi
}
status_varnishd() {
start-stop-daemon \
--status --pidfile $PIDFILE \
--exec $DAEMON
exit $?
}
configtest() {
log_daemon_msg "Checking syntax" "$SERVICE"
$DAEMON ${DAEMON_OPTS} -C -n /tmp 1>/dev/null 2>&1
local ret=${?:-1}
log_end_msg $ret
if [ $ret != 0 ]; then
$DAEMON ${DAEMON_OPTS} -C -n /tmp
fi
return $ret
}
case "$1" in
start)
case "${START:-}" in
[Yy]es|[Yy]|1|[Tt]|[Tt]rue)
start_varnishd
;;
*)
disabled_varnishd
;;
esac
;;
stop)
stop_varnishd
;;
reload)
reload_varnishd
;;
status)
status_varnishd
;;
restart|force-reload)
$0 stop
$0 start
;;
configtest)
configtest
;;
*)
log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload|configtest}"
exit 1
;;
esac
/var/log/varnish/varnishncsa.log {
daily
rotate 7
compress
delaycompress
missingok
postrotate
if [ -d /run/systemd/system ]; then
systemctl -q is-active varnishncsa.service || exit 0
fi
/usr/sbin/invoke-rc.d varnishncsa reload > /dev/null
endscript
}
#! /bin/sh
### BEGIN INIT INFO
# Provides: varnishncsa
# Required-Start: $local_fs $remote_fs $network varnish
# Required-Stop: $local_fs $remote_fs $network varnish
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start HTTP accelerator log daemon
# Description: This script provides logging for varnish
### END INIT INFO
# Source function library
. /lib/lsb/init-functions
NAME=varnishncsa
DESC="HTTP accelerator log deamon"
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/$NAME
PIDFILE=/run/$NAME/$NAME.pid
LOGFILE=/var/log/varnish/varnishncsa.log
USER=varnishlog
GROUP=varnish
DAEMON_OPTS="-a -w ${LOGFILE} -D -P ${PIDFILE}"
# Include defaults if available
if [ -f /etc/default/$NAME ] ; then
. /etc/default/$NAME
fi
# If unset, or set to "0" or "no", exit
if [ -z "${VARNISHNCSA_ENABLED}" ] || \
[ "${VARNISHNCSA_ENABLED}" = "0" ] || \
[ "${VARNISHNCSA_ENABLED}" = "no" ]; then
exit 0;
fi
test -x $DAEMON || { echo "${DAEMON} has no execute bit"; exit 0; }
start_varnishncsa() {
output=$(/bin/tempfile -s.varnish)
log_daemon_msg "Starting $DESC" "$SERVICE"
create_pid_directory
if start-stop-daemon --start --pidfile ${PIDFILE} \
--chuid $USER --exec ${DAEMON} -- ${DAEMON_OPTS} \
> ${output} 2>&1; then
log_end_msg 0
else
log_end_msg 1
cat $output
exit 1
fi
rm $output
}
disabled_varnishncsa() {
log_daemon_msg "Not starting $DESC" "$SERVICE"
log_progress_msg "disabled in /etc/default/varnishncsa"
log_end_msg 0
}
stop_varnishncsa(){
log_daemon_msg "Stopping $DESC" "$SERVICE"
if start-stop-daemon --stop --pidfile $PIDFILE \
--retry 10 --exec $DAEMON; then
log_end_msg 0
else
log_end_msg 1
fi
}
reload_varnishncsa(){
log_daemon_msg "Reloading $DESC" "$SERVICE"
if kill -HUP $(cat $PIDFILE) >/dev/null 2>&1; then
log_end_msg 0
else
log_end_msg 1
exit 1
fi
}
status_varnishncsa(){
status_of_proc -p "${PIDFILE}" "${DAEMON}" "${SERVICE}"
exit $?
}
create_pid_directory() {
install -o $USER -g $GROUP -d $(dirname $PIDFILE)
}
case "$1" in
start)
case "${VARNISHNCSA_ENABLED:-}" in
[Yy]es|[Yy]|1|[Tt]|[Tt]rue)
start_varnishncsa
;;
*)
disabled_varnishncsa
;;
esac
;;
stop)
stop_varnishncsa
;;
reload)
reload_varnishncsa
;;
status)
status_varnishncsa
;;
restart|force-reload)
$0 stop
$0 start
;;
*)
log_success_msg "Usage: $0 {start|stop|restart|force-reload|reload}"
exit 1
;;
esac
#!/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/varnishreload"
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/varnishncsa.log {
daily
rotate 7
compress
delaycompress
missingok
postrotate
/bin/kill -HUP `cat /var/run/varnishncsa.pid /run/varnishncsa/varnishncsa.pid 2>/dev/null` 2> /dev/null || true
endscript
}
# 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.
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
#
#
# 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} \
-p thread_pool_min=${VARNISH_MIN_THREADS} \
-p thread_pool_max=${VARNISH_MAX_THREADS} \
-s ${VARNISH_STORAGE}"
#! /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 $?
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