Skip to content

Instantly share code, notes, and snippets.

@greg-1-anderson
Last active November 12, 2021 20:52
Show Gist options
  • Save greg-1-anderson/07d8488cb79d108503fa2923f7662aa9 to your computer and use it in GitHub Desktop.
Save greg-1-anderson/07d8488cb79d108503fa2923f7662aa9 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}
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"
terminus lock:enable "$SITE.$ENV" "$USER" "$PASSWORD"
fi
done
@aaronbauman
Copy link

For the lazy, to lock all environments across all sites:

#!/bin/bash                                                                                                                                                     

USER={USER}
PASSWORD={PASSWORD}

ALL_SITES="$(terminus site:list --fields=name --format=list)"
for SITE in $ALL_SITES ; do
  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"
      terminus lock:enable "$SITE.$ENV" "$USER" "$PASSWORD"
    fi
  done
done





@uberhacker
Copy link

uberhacker commented Jun 30, 2018

@aaronbauman @greg-1-anderson: Nice! Terminus plugin candidate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment