Last active
April 30, 2019 14:00
-
-
Save heathdutton/5fd2fff9353b3f475cfb to your computer and use it in GitHub Desktop.
Acquia Cloud hook for flushing Varnish .com domains securely.
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
#!/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