Skip to content

Instantly share code, notes, and snippets.

@dwaghmare
Forked from heathdutton/50_purge_varnish.sh
Last active August 29, 2015 14:21
Show Gist options
  • Save dwaghmare/8273338b65222ba39cc2 to your computer and use it in GitHub Desktop.
Save dwaghmare/8273338b65222ba39cc2 to your computer and use it in GitHub Desktop.
#!/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