forked from btcpayserver/btcpayserver-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
btcpay-teardown.sh
executable file
·51 lines (40 loc) · 1.61 KB
/
btcpay-teardown.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
#!/bin/bash
set +x
if [[ "$0" = "$BASH_SOURCE" ]]; then
echo "This script must be sourced \". btcpay-teardown.sh\""
exit 1
fi
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root after running \"sudo su -\""
return
fi
# Verify we are in right folder. If we are not, let's go in the parent folder of the current docker-compose.
if ! git rev-parse --git-dir &> /dev/null || [ ! -d "Generated" ]; then
if [[ ! -z $BTCPAY_DOCKER_COMPOSE ]]; then
cd $(dirname $BTCPAY_DOCKER_COMPOSE)
cd ..
fi
if ! git rev-parse || [[ ! -d "Generated" ]]; then
echo "You must run this script inside the git repository of btcpayserver-docker"
return
fi
fi
printf "\n🚨 Running this script will completely erase the BTCPay Server instance. Do you wish to perform this action?\n\n"
read -p "➡️ Confirm by typing 'YES': " confirm
if [[ "$confirm" != "YES"* ]]; then
printf "\n😌 Phew, that was close. Aborting uninstall — thanks for keeping your BTCPay Server!\n\n"
return
else
printf "\n👋 Sad to see you go. Thanks for using BTCPay Server!\n"
fi
BASH_PROFILE_SCRIPT="/etc/profile.d/btcpay-env.sh"
ORIGINAL_DIRECTORY="$(pwd)"
BTCPAY_BASE_DIRECTORY="$(dirname "$(pwd)")"
printf "\nℹ️ Stopping BTCPay Server and removing related Docker volumes and networks …\n\n"
docker-compose -f $BTCPAY_DOCKER_COMPOSE down -v
docker system prune -f
printf "\nℹ️ Removing BTCPay Server files …\n\n"
cd $BTCPAY_BASE_DIRECTORY
rm -rf $ORIGINAL_DIRECTORY
rm $BASH_PROFILE_SCRIPT $BTCPAY_ENV_FILE
printf "\n✅ Teardown done, successfully uninstalled BTCPay Server!\n\n"