Skip to content

Instantly share code, notes, and snippets.

@quicksketch
Created March 30, 2020 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quicksketch/917f7fc00a7544d17cfed48c79ebba48 to your computer and use it in GitHub Desktop.
Save quicksketch/917f7fc00a7544d17cfed48c79ebba48 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
export PANTHEON_ENV="dev"
export PANTHEON_MACHINE_TOKEN="s7IOagnSGKr01KClaIxJwjxaaV7Tm9d0WAWp9jJZ2iatD"
# Stash org UUID
ORG_UUID="1a93e694-1903-411d-8c35-fa2d4292f9f8"
# Authenticate with Terminus
terminus auth:login --machine-token=$PANTHEON_MACHINE_TOKEN
# Stash list of all Pantheon sites in the org
PANTHEON_SITES="$(terminus org:site:list -n ${ORG_UUID} --format=list --field=Name)"
# Convert the newline-separated list to an array.
# See https://stackoverflow.com/questions/24628076/bash-convert-n-delimited-strings-into-array
SAVEIFS=$IFS # Save current IFS
IFS=$'\n' # Change IFS to new line
PANTHEON_SITES=($PANTHEON_SITES) # Conver to an array.
IFS=$SAVEIFS # Restore IFS
# Loop through each site in the list
for (( i=0; i<${#PANTHEON_SITES[@]}; i++ )); do
PANTHEON_SITE_NAME=${PANTHEON_SITES[$i]}
# Check if the site is frozen
IS_FROZEN="$(terminus site:info $PANTHEON_SITE_NAME --field=frozen)"
# If the site is frozen
if [[ "true" == "${IS_FROZEN}" ]]
then
# Then skip it
echo -e "Skipping updating the site '$PANTHEON_SITE_NAME' because it is frozen...\n"
else
~terminus env:wake $PANTHEON_SITE_NAME.$PANTHEON_ENV
# TODO - Figure out why uncommenting the below line kills the while loop
echo "Site name: $PANTHEON_SITE_NAME";
terminus drush $PANTHEON_SITE_NAME.$PANTHEON_ENV -- cr -y
echo "Site name: $PANTHEON_SITE_NAME";
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment