summaryrefslogtreecommitdiff
path: root/extra/varnish/varnish-vcl-reload
diff options
context:
space:
mode:
Diffstat (limited to 'extra/varnish/varnish-vcl-reload')
-rw-r--r--extra/varnish/varnish-vcl-reload21
1 files changed, 21 insertions, 0 deletions
diff --git a/extra/varnish/varnish-vcl-reload b/extra/varnish/varnish-vcl-reload
new file mode 100644
index 000000000..aaac385c4
--- /dev/null
+++ b/extra/varnish/varnish-vcl-reload
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+cfg=${1:-/etc/varnish/default.vcl}
+
+if [ ! -e "$cfg" ]; then
+ printf 'ERROR: VCL file %s does not exist\n' "$cfg" >&2
+ exit 1
+fi
+
+activecfg=$(varnishadm 'vcl.list' | awk '/active/ { print $3 }')
+if [ -z "$activecfg" ]; then
+ printf 'ERROR: No active VCL found!\n' >&2
+ exit 1
+fi
+
+newcfg=$(date +'vcl-%s')
+printf 'INFO: using new config %s\n' "$cfg"
+
+varnishadm "vcl.load $newcfg $cfg" &&
+varnishadm "vcl.use $newcfg" &&
+varnishadm "vcl.discard $activecfg"