Last active
April 3, 2016 12:20
-
-
Save teknikqa/d7cfadf4de25fd3676eab75617e5dddb to your computer and use it in GitHub Desktop.
Script to manually purge the cache on Acquia load balancers. It can accept a path that needs to be purged from the cache.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# This script will purge the Varnish cache on Acquia for the given URLs | |
# Requires cURL | |
# | |
# Usage purge-cache.sh <url> | |
# Author: Nick Mathew <nm7.org> | |
# Date: 2016-04-03 | |
# | |
# Replace these values with appropriate ones for your Acquia server | |
BALANCERS="1 2" | |
declare -a HOSTS=('host1' 'host2') | |
declare -a HOSTNAMES=('name1' 'name2') | |
if ((${#HOSTNAMES[@]} != ${#HOSTS[@]})) | |
then | |
echo "Mismatch in hosts and hostnames. Please make sure that each host has got a corresponding hostname." | |
exit 1 | |
else | |
# If no argument is passed, the cache of the homepage is flushed. | |
if [ $# -ge 1 ] | |
then | |
# Only use the first argument. Ignore everything else. | |
URL="/"$1 | |
echo $URL | |
fi | |
for (( i=0; $i<${#HOSTNAMES[@]}; i=$i+1)); | |
do | |
echo "${HOSTNAMES[i]} - ${HOSTS[i]}" | |
for balancer in $BALANCERS; | |
do | |
echo "Purging Varnish cache of website on $balancer" | |
curl -X PURGE -H "X-Acquia-Purge:[gtsfsdoha]" --compress -H "Host: ${HOSTS[i]}" http://bal-$balancer.prod.hosting.acquia.com$URL | |
echo "Purging Varnish cache of https website on $balancer" | |
curl -k -X PURGE -H "X-Acquia-Purge:[gtsfsdoha]" --compress -H "Host: ${HOSTS[i]}" https://bal-$balancer.prod.hosting.acquia.com$URL | |
done | |
echo "" | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment