Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

# The purpose of this script is to make it easy to reset a local onpremise
# install to a clean state, optionally targeting a particular version.

set -euo pipefail

if [ -n "${DEBUG:-}" ]; then
set -x
fi

cd "$(dirname $0)"


function confirm () {
read -p "$1 [y/n] " confirmation
if [ "$confirmation" != "y" ]; then
echo "Canceled. 😅"
exit
fi
}


# If we have a version given, validate it.
# ----------------------------------------
# Note that arbitrary git refs won't work, because the *_IMAGE variables in
# .env will almost certainly point to :latest. Tagged releases are generally
# the only refs where these component versions are pinned, so enforce that
# we're targeting a valid tag here. Do this early in order to fail fast.

version="${1:-}"
if [ -n "$version" ]; then
set +e
git rev-parse --verify --quiet "refs/tags/$version" > /dev/null
if [ $? -gt 0 ]; then
echo "Bad version: $version"
exit
fi
set -e
fi

# Make sure they mean it.
confirm "☠️ Warning! 😳 This is highly destructive! 😱 Are you sure you wish to proceed?"
echo "Okay ... good luck! 😰"

# Hit the reset button.
docker compose down --volumes --remove-orphans --rmi local

# Remove any remaining (likely external) volumes with name matching 'sentry-.*'.
for volume in $(docker volume list --format '{{ .Name }}' | grep '^sentry-'); do
docker volume remove $volume > /dev/null \
&& echo "Removed volume: $volume" \
|| echo "Skipped volume: $volume"
done

# If we have a version given, switch to it.
if [ -n "$version" ]; then
git checkout "$version"
fi

# Install.
exec ./install.sh