-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathdappnode_uninstall.sh
More file actions
executable file
·80 lines (67 loc) · 2.4 KB
/
dappnode_uninstall.sh
File metadata and controls
executable file
·80 lines (67 loc) · 2.4 KB
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
#!/usr/bin/env bash
DAPPNODE_DIR="/usr/src/dappnode"
DAPPNODE_CORE_DIR="${DAPPNODE_DIR}/DNCORE"
PROFILE_FILE="${DAPPNODE_CORE_DIR}/.dappnode_profile"
input=$1 # Allow to call script with argument (must be Y/N)
[ -f $PROFILE_FILE ] || (
echo "Error: DAppNode profile does not exist."
exit 1
)
uninstall() {
echo -e "\e[32mUninstalling DAppNode\e[0m"
# shellcheck disable=SC1090
source "${PROFILE_FILE}" &>/dev/null
DAPPNODE_CONTAINERS="$(docker ps -a --format '{{.Names}}' | grep DAppNode)"
echo -e "\e[32mRemoving DAppNode containers: \e[0m\n${DAPPNODE_CONTAINERS}"
for container in $DAPPNODE_CONTAINERS; do
# Stop DAppNode container
docker stop "$container" &>/dev/null
# Remove DAppNode container
docker rm "$container" &>/dev/null
done
DAPPNODE_IMAGES="$(docker image ls -a | grep "dappnode")"
echo -e "\e[32mRemoving DAppNode images: \e[0m\n${DAPPNODE_IMAGES}"
for image in $DAPPNODE_IMAGES; do
# Remove DAppNode images
docker image rm "$image" &>/dev/null
done
DAPPNODE_VOLUMES="$(docker volume ls | grep "dappnode\|dncore")"
echo -e "\e[32mRemoving DAppNode volumes: \e[0m\n${DAPPNODE_VOLUMES}"
for volume in $DAPPNODE_VOLUMES; do
# Remove DAppNode volumes
docker volume rm "$volume" &>/dev/null
done
# Remove dncore_network
echo -e "\e[32mRemoving docker dncore_network\e[0m"
docker network remove dncore_network || echo "dncore_network already removed"
# Remove dir
echo -e "\e[32mRemoving DAppNode directory\e[0m"
rm -rf /usr/src/dappnode
# Remove profile file references from shell config files
USER=$(grep 1000 /etc/passwd | cut -f 1 -d:)
[ -n "$USER" ] && USER_HOME=/home/$USER || USER_HOME=/root
for config_file in .profile .bashrc; do
CONFIG_PATH="$USER_HOME/$config_file"
if [ -f "$CONFIG_PATH" ]; then
sed -i '/######## DAPPNODE PROFILE ########/d' "$CONFIG_PATH"
sed -i '/.*dappnode_profile/d' "$CONFIG_PATH"
fi
done
echo -e "\e[32mDAppNode uninstalled!\e[0m"
}
if [ $# -eq 0 ]; then
read -r -p "WARNING: This script will uninstall and delete all DAppNode
containers and volumes. Are You Sure? [Y/n] " input <&2
fi
case $input in
[yY][eE][sS] | [yY])
uninstall
;;
[nN][oO] | [nN])
echo "Ok."
;;
*)
echo "Invalid input. Exiting..."
exit 1
;;
esac