Skip to content

Instantly share code, notes, and snippets.

@kporras07
Forked from greg-1-anderson/lock-all-environments
Last active March 28, 2018 20:36
Show Gist options
  • Save kporras07/937758f3fdc80570bc2269fc8a8842fa to your computer and use it in GitHub Desktop.
Save kporras07/937758f3fdc80570bc2269fc8a8842fa to your computer and use it in GitHub Desktop.
Lock all of the environments for the given site, save for the live environment
#!/bin/bash
SITE=$1
USER=${2-demo}
BASE_PASSWORD=${3-secretsecret}
ALL_ENVS="$(terminus env:list $SITE --field=id | grep -v live)"
for ENV in $ALL_ENVS ; do
is_locked="$(terminus lock:info "$SITE.$ENV" --field=locked)"
if [[ "$is_locked" == "true" ]] ; then
echo "# $SITE.$ENV is already locked"
else
echo "# Locking $SITE.$ENV"
PASSWORD=$ENV$BASE_PASSWORD
terminus lock:enable "$SITE.$ENV" "$USER" "$PASSWORD"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment