From 59c52f775f05d98ed505106a3aa1c139afe935dc Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 15 Nov 2016 08:49:54 -0500 Subject: [PATCH] add purge varnish hook (initial) --- contrib/tools/hooks/purge-varnish.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 contrib/tools/hooks/purge-varnish.sh diff --git a/contrib/tools/hooks/purge-varnish.sh b/contrib/tools/hooks/purge-varnish.sh new file mode 100755 index 0000000..1cfe863 --- /dev/null +++ b/contrib/tools/hooks/purge-varnish.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# this script can be called via hooks for each post to purge varnish cache on new post +# + +if [ "$3" == "" ] ; then + op="$2" +else + op="$3" +fi + +# ip to bind to when doing http request +ip="127.0.1.1" + +# purge thread page +curl --interface "$ip" -v -X PURGE http://$varnish/thread-$(sha1sum <<< "$op" | cut -d' ' -f1).html +# purge board page +curl --interface "$ip" -v -X PURGE http://$varnish/$1-0.html