mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-05-08 13:44:40 +02:00
58 lines
1.1 KiB
Bash
58 lines
1.1 KiB
Bash
#!/sbin/openrc-run
|
|
# Copyright 1999-2014 Gentoo Foundation
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
VARNISHD_PID=${VARNISHD_PID:-/run/${SVCNAME}.pid}
|
|
CONFIGFILES="${CONFIGFILE:-/etc/varnish/default.vcl}"
|
|
|
|
command="${VARNISHD:-/usr/sbin/varnishd}"
|
|
command_args="-j unix,user=varnish -P ${VARNISHD_PID} -f ${CONFIGFILE} ${VARNISHD_OPTS}"
|
|
pidfile="${VARNISHD_PID}"
|
|
|
|
extra_commands="configtest"
|
|
extra_started_commands="reload"
|
|
|
|
description_configtest="Run syntax tests for configuration files."
|
|
description_reload="Reloads the configuration."
|
|
|
|
depend() {
|
|
need net
|
|
}
|
|
|
|
configtest() {
|
|
ebegin "Checking ${SVCNAME} configuration"
|
|
checkconfig
|
|
eend $?
|
|
}
|
|
|
|
checkconfig() {
|
|
${VARNISHD} -C -f ${CONFIGFILE} >/dev/null 2>&1
|
|
ret=$?
|
|
if [ $ret -ne 0 ]; then
|
|
eerror "${SVCNAME} has detected an error in your setup:"
|
|
${VARNISHD} -C -f ${CONFIGFILE}
|
|
fi
|
|
|
|
return $ret
|
|
}
|
|
|
|
start_pre() {
|
|
checkconfig || return 1
|
|
}
|
|
|
|
stop_pre() {
|
|
if [ "${RC_CMD}" = "restart" ]; then
|
|
checkconfig || return 1
|
|
fi
|
|
}
|
|
|
|
reload() {
|
|
checkconfig || return 1
|
|
|
|
ebegin "Reloading varnish"
|
|
|
|
output="$VARNISHRELOAD 2>&1"
|
|
|
|
eend $? "${SVCNAME} couldn't reload its configuration:
|
|
$output"
|
|
}
|