forked from inv4fee2020/xf_node
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path_reset_xahl_node.sh
executable file
·129 lines (111 loc) · 4.32 KB
/
_reset_xahl_node.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
# Set Colour Vars
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${RED}#########################################################################"
echo -e "${RED}#########################################################################"
echo -e "${RED}"
echo -e "${RED} !! WARNING !!${NC} Xahaud Reset Script ${RED}!! WARNING !!${NC}"
echo -e "${RED}"
echo -e "${RED} Not recommended for production use, used for testing script setup.${NC}"
echo -e "${RED}#########################################################################"
echo -e "${RED}#########################################################################${NC}"
echo
echo
echo
# Ask the user acc for login details (comment out to disable)
CHECK_PASSWD=false
while true; do
read -t10 -r -p ":: DESTRUCTIVE :: Confirm that you wish to RESET your Xahaud node installation ? (Y/n) " _input
if [ $? -gt 128 ]; then
#clear
echo
echo "timed out waiting for user response - quitting..."
exit 0
fi
case $_input in
[Yy][Ee][Ss]|[Yy]* )
break
;;
[Nn][Oo]|[Nn]* )
exit 0
;;
* ) echo "Please answer (y)es or (n)o.";;
esac
done
# Authenticate sudo perms before script execution to avoid timeouts or errors
sudo -l > /dev/null 2>&1
# Load the vars file
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
source $SCRIPT_DIR/xahl_node.vars
echo -e "${YELLOW}$USER_DNS_RECORDS${NC}"
IFS=',' read -ra DOMAINS_ARRAY <<< "$USER_DNS_RECORDS"
A_RECORD="${DOMAINS_ARRAY[0]}"
CNAME_RECORD1="${DOMAINS_ARRAY[1]}"
CNAME_RECORD2="${DOMAINS_ARRAY[2]}"
if [ $VARVAL_CHAIN_NAME = "mainnet" ]; then
VARVAL_CHAIN_PEER="$XAHL_MAINNET_PEER"
VARVAL_CHAIN_REPO="mainnet-docker"
fi
if [ $VARVAL_CHAIN_NAME = "testnet" ]; then
VARVAL_CHAIN_PEER="$XAHL_TESTNET_PEER"
VARVAL_CHAIN_REPO="Xahau-Testnet-Docker"
fi
# Stop nginx and xahaud processes, clean up
sudo systemctl stop nginx.service \
&& sudo systemctl disable nginx.service \
&& sudo rm -rfv /run/nginx.pid \
&& sudo rm -rfv /usr/sbin/nginx
sudo systemctl stop xahaud.service \
&& sudo systemctl disable xahaud.service \
&& sudo rm -rfv /etc/systemd/system/xahaud.service
sudo systemctl daemon-reload
# Remove and clean up landingpage
sudo rm -fv $NGX_CONF_ENABLED/xahau
sudo rm -fv $NGX_CONF_AVAIL/xahau
sudo rm -rfv /home/www
# Remove and clean up nginx
sudo rm -rfv $SCRIPT_DIR/nginx_allowlist.conf
sudo rm -rfv /var/www
sudo apt --purge remove fontconfig-config fonts-dejavu-core libdeflate0 \
libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip2 \
libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream \
libnginx-mod-stream-geoip2 libtiff5 libwebp7 libxpm4 nginx-common nginx-core -y
# Remove firewall rules
sudo ufw delete allow $VARVAL_CHAIN_PEER/tcp
sudo ufw delete allow 'Nginx Full'
sudo ufw status verbose
# Remove and clean up xahaud
echo -e $VARVAL_CHAIN_REPO
if [ -z $VARVAL_CHAIN_REPO ]; then
echo -e "VARVAL_CHAIN_REPO is not defined for some reason. Exiting before I nuke the home folder."
exit 1
else
sudo rm -rfv $SCRIPT_DIR/$VARVAL_CHAIN_REPO
fi
sudo userdel xahaud
sudo rm -rfv /opt/xahaud
sudo rm -rfv /usr/local/bin/xahaud
sudo rm -rfv /usr/local/bin/xahaud-install-update.sh
# Clean up logrotate
sudo rm -rfv /etc/logrotate.d/nginx
sudo rm -rfv /etc/logrotate.d/xahau-logs
# Remove and clean up certbot
sudo certbot revoke --cert-path /etc/letsencrypt/live/$A_RECORD/fullchain.pem --non-interactive
sudo apt --purge remove certbot python3-certbot-nginx python3-acme python3-certbot python3-certifi \
python3-configargparse python3-icu python3-josepy python3-parsedatetime python3-requests \
python3-requests-toolbelt python3-rfc3339 python3-tz python3-urllib3 python3-zope.component \
python3-zope.event python3-zope.hookable -y
sudo rm -rfv /var/log/letsencrypt
# Clean up files in home directory
sudo rm -rfv $SCRIPT_DIR/$NGINX_WSS_ALLOWLIST
sudo rm -rfv $SCRIPT_DIR/$NGINX_RPC_ALLOWLIST
echo
echo
echo
echo
echo -e "${RED} Removal of xahaud and associated setup completed.${NC}"
echo
echo
echo