-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuninstall_ui.sh
130 lines (110 loc) · 3.56 KB
/
uninstall_ui.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
130
#!/bin/bash
# Check for color support
if [ -t 1 ]; then
ncolors=$( tput colors )
if [ -n "${ncolors}" -a "${ncolors}" -ge 8 ]; then
if normal="$( tput sgr0 )"; then
# Use terminfo names
red="$( tput setaf 1 )"
green="$( tput setaf 2)"
yellow="$( tput setaf 3)"
blue="$( tput setaf 4)"
magenta="$( tput setaf 5)"
cyan="$( tput setaf 6)"
white="$( tput setaf 7)"
else
# Use termcap names for FreeBSD compat
normal="$( tput me )"
red="$( tput AF 1 )"
green="$( tput AF 2)"
yellow="$( tput AF 3)"
blue="$( tput AF 4)"
magenta="$( tput AF 5)"
cyan="$( tput AF 6)"
white="$( tput AF 7)"
fi
fi
fi
# For security reasons user shuld not run as root
echo ""
echo "Checking to ensure ${red}root${normal} user is not being utilized"
echo "and script was not called with ${red}sudo${normal} priveliges..."
sleep 2
echo ""
if [ "$_user" = "root" ]; then
echo "${red}Root user login detected...${normal}"
sleep 1
echo "${red}Qoral-UI uninstall script for Linux will now exit, goodbye!${normal}"
sleep 2
echo ""
# Exit under general error
exit 1
elif [ "$SUDO_USER" != "" ]; then
echo "${red}Script was called via sudo...${normal}"
sleep 1
echo "Qoral-UI uninstall script for Linux will now exit, goodbye!"
sleep 2
echo ""
# Exit under general error
exit 1
elif [ "$_user" != "root" ] && [ "$SUDO_USER" = "" ]; then
# Small intro and declaration of versioning
echo "==========================================================================="
echo " Qortal-UI uninstall script for Linux by ${cyan}HFactor${normal} (V4.0) "
echo "==========================================================================="
echo ""
sleep 2
echo "This script will build the Qortal-UI from soruce and will require ${red}sudo${normal}"
echo "privileges for one or more calls before script completion..."
sleep 3
echo "Please enter the appropriate password when asked to ${red}avoid${normal} permissions errors!"
sleep 4
echo ""
# Disable mouse cursor
tput civis
echo "${green}Starting${normal} Qortal-UI removal via npm which may take a while...please be patient!"
echo ""
echo "${red}Stopping${normal} node.js if running..."
killall -9 node
echo ""
# Uninstall and remove qortal-ui modules via npm
echo "${red}Uninstalling${normal} Qortal-UI via npm..."
cd qortal-ui
sudo npm uninstall qortal-ui
sudo npm rm qortal-ui
cd ..
echo ""
echo "${red}Removing${normal} NPM and NodeJS"
sudo apt purge -y nodejs
sudo rm -rf /etc/apt/sources.list.d/nodesource.list
sudo rm -rf /etc/apt/keyrings/nodesource.gpg
echo ""
echo "${green}Cleaning${normal} up nodeJS remnants..."
sleep 1
echo ""
echo "${green}Cleaning${normal} up straggling files and directories..."
rm -rf $PWD/.npm
rm -rf $PWD/.node-gyp
rm -rf $PWD/tmp/rollup-plugins-progress
sleep 1
echo ""
echo "${green}Cleaning${normal} up APT..."
sudo apt -y autoremove
sudo apt clean
echo ""
echo "${red}Removing${normal} Qortal-UI folder stragglers if any..."
rm -rf qortal-ui
echo ""
echo "${green}Qortal-UI has now been uninstalled, Goodbye!${normal}"
# Re-enable mouse cursor
tput cnorm
# Read user typed key into "input" and return after reading 1 character (-n 1) without echoing to the term (-s)
echo "Press ${cyan}q${normal} to exit!"
while read -s -n 1 input; do
case "${input}" in
(q) break ;;
(*) echo "${red}Invalid key pressed!${normal}" ;;
esac
done
fi
exit 0