Skip to content

Instantly share code, notes, and snippets.

@teknikqa
Forked from heathdutton/50_purge_varnish.sh
Created July 21, 2016 13:09
Show Gist options
  • Save teknikqa/451b99d27bffd78fceee89364d0569be to your computer and use it in GitHub Desktop.
Save teknikqa/451b99d27bffd78fceee89364d0569be to your computer and use it in GitHub Desktop.
Acquia Cloud hook for flushing Varnish .com domains securely.
#!/bin/bash
#
# Cloud Hooks: code-deploy, code-update, db-copy, web-activate
# Essentially any time code or db changes are made.
#
# Purges Varnish cache for all .com domains assigned to the environment in Acquia Cloud.
site="$1"
target_env="$2"
drush_alias=$site'.'$target_env
json="$(drush @$drush_alias ac-domain-list --format=json)"
if [ "$?" -ne "0" ]; then
echo "The environment needs to have login permissions in order to purge Varnish."
echo "Run the following to have the environment log in securely:"
echo " drush @$drush_alias ssh 'drush ac-api-login'"
else
domains="$(echo $json | tr '"' '\n' | grep .com)"
echo "Flushing .com domains in Varnish for this environment..."
for domain in ${domains[@]}
do
echo " Flushing $domain"
drush @$drush_alias ac-domain-purge $domain
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment