mirror of
https://github.com/getsentry/self-hosted.git
synced 2025-12-08 19:46:14 +00:00
Make a reset button (#988)
This commit is contained in:
parent
8d92667f4e
commit
0cfaa73b05
62
reset.sh
Executable file
62
reset.sh
Executable file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user