forked from getsentry/self-hosted
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.sh
executable file
·62 lines (48 loc) · 1.6 KB
/
reset.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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.
./install.sh