-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUninstall.sh
More file actions
337 lines (302 loc) Β· 9.67 KB
/
Uninstall.sh
File metadata and controls
337 lines (302 loc) Β· 9.67 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#!/bin/bash
# DomainShield Uninstaller
# Author: Debajyoti0-0
# Description: Removes DomainShield and optional tools
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to detect package manager
detect_package_manager() {
if command_exists apt; then
echo "apt"
elif command_exists yum; then
echo "yum"
elif command_exists dnf; then
echo "dnf"
elif command_exists pacman; then
echo "pacman"
elif command_exists zypper; then
echo "zypper"
else
echo "unknown"
fi
}
# Function to remove package
remove_package() {
local pm="$1"
local package="$2"
local name="$3"
if ! command_exists "$package" 2>/dev/null; then
print_status "$name is not installed"
return 0
fi
print_status "Removing $name..."
case $pm in
apt)
sudo apt remove -y "$package" >/dev/null 2>&1
;;
yum)
sudo yum remove -y "$package" >/dev/null 2>&1
;;
dnf)
sudo dnf remove -y "$package" >/dev/null 2>&1
;;
pacman)
sudo pacman -R --noconfirm "$package" >/dev/null 2>&1
;;
zypper)
sudo zypper remove -y "$package" >/dev/null 2>&1
;;
esac
if ! command_exists "$package" 2>/dev/null; then
print_success "$name removed successfully"
return 0
else
print_error "Failed to remove $name"
return 1
fi
}
# Function to remove symlink
remove_symlink() {
print_status "Removing DomainShield symlink..."
if [ -L "/usr/local/bin/domainshield" ]; then
if sudo rm "/usr/local/bin/domainshield" 2>/dev/null; then
print_success "Symlink removed: /usr/local/bin/domainshield"
return 0
else
print_error "Failed to remove symlink. You may need to run with sudo."
return 1
fi
else
print_status "DomainShield symlink not found"
return 0
fi
}
# Function to get package names based on package manager
get_package_names() {
local pm="$1"
case $pm in
apt)
echo "dnsutils whois curl openssl netcat"
;;
yum|dnf)
echo "bind-utils whois curl openssl nc"
;;
pacman)
echo "bind-tools whois curl openssl netcat"
;;
zypper)
echo "bind-utils whois curl openssl netcat"
;;
esac
}
# Function to get tool names for display
get_tool_names() {
echo "dnsutils,whois,curl,openssl,netcat"
}
# Function to check yes/no input
confirm_yes_no() {
local prompt="$1"
local default="${2:-no}"
while true; do
read -p "$prompt [y/N]: " answer
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]')
case "$answer" in
y|yes)
return 0
;;
n|no|"")
return 1
;;
*)
echo "Please answer yes (y) or no (n)."
;;
esac
done
}
# Function to uninstall tools
uninstall_tools() {
local pm="$1"
local selection="$2"
case $pm in
apt)
case $selection in
dnsutils) remove_package "$pm" "dnsutils" "dnsutils (dig/nslookup)" ;;
whois) remove_package "$pm" "whois" "whois" ;;
curl) remove_package "$pm" "curl" "curl" ;;
openssl) remove_package "$pm" "openssl" "openssl" ;;
netcat) remove_package "$pm" "netcat" "netcat" ;;
esac
;;
yum|dnf)
case $selection in
dnsutils) remove_package "$pm" "bind-utils" "bind-utils (dig/nslookup)" ;;
whois) remove_package "$pm" "whois" "whois" ;;
curl) remove_package "$pm" "curl" "curl" ;;
openssl) remove_package "$pm" "openssl" "openssl" ;;
netcat) remove_package "$pm" "nc" "netcat" ;;
esac
;;
pacman)
case $selection in
dnsutils) remove_package "$pm" "bind-tools" "bind-tools (dig/nslookup)" ;;
whois) remove_package "$pm" "whois" "whois" ;;
curl) remove_package "$pm" "curl" "curl" ;;
openssl) remove_package "$pm" "openssl" "openssl" ;;
netcat) remove_package "$pm" "netcat" "netcat" ;;
esac
;;
zypper)
case $selection in
dnsutils) remove_package "$pm" "bind-utils" "bind-utils (dig/nslookup)" ;;
whois) remove_package "$pm" "whois" "whois" ;;
curl) remove_package "$pm" "curl" "curl" ;;
openssl) remove_package "$pm" "openssl" "openssl" ;;
netcat) remove_package "$pm" "netcat" "netcat" ;;
esac
;;
esac
}
# Function to handle tool uninstallation
handle_tool_uninstallation() {
local pm="$1"
echo
if confirm_yes_no "Do you want to uninstall any tools?"; then
echo
print_status "Available tools to uninstall:"
echo -e "${YELLOW}$(get_tool_names)${NC}"
echo
echo "You can:"
echo " - Type 'all' to uninstall all tools"
echo " - Type a specific tool name (e.g., dnsutils)"
echo " - Type 'none' to skip tool uninstallation"
echo
while true; do
read -p "Enter your choice: " choice
choice=$(echo "$choice" | tr '[:upper:]' '[:lower:]')
case "$choice" in
all)
echo
print_status "Uninstalling all tools..."
echo
uninstall_tools "$pm" "dnsutils"
uninstall_tools "$pm" "whois"
uninstall_tools "$pm" "curl"
uninstall_tools "$pm" "openssl"
uninstall_tools "$pm" "netcat"
break
;;
dnsutils|whois|curl|openssl|netcat)
echo
uninstall_tools "$pm" "$choice"
break
;;
none|skip)
print_status "Skipping tool uninstallation"
break
;;
"")
print_status "No input provided, skipping tool uninstallation"
break
;;
*)
print_error "Invalid choice: $choice"
echo "Valid choices: all, dnsutils, whois, curl, openssl, netcat, none"
echo
;;
esac
done
else
print_status "Skipping tool uninstallation"
fi
}
# Main uninstallation function
main() {
clear
echo -e "${RED}"
cat << "EOF"
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DomainShield Uninstaller β
β DNS & EMAIL SECURITY AUDITOR β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
EOF
echo -e "${NC}"
echo
# Check if user is root or has sudo privileges
if [ "$EUID" -ne 0 ] && ! command_exists sudo && ! command_exists su; then
print_error "This script requires sudo privileges or root access"
exit 1
fi
# Remove symlink
remove_symlink
# Detect package manager for tool uninstallation
PM=$(detect_package_manager)
if [ "$PM" = "unknown" ]; then
print_warning "Unsupported package manager detected."
print_status "Skipping tool uninstallation (manual removal required)"
else
print_success "Detected package manager: $PM"
handle_tool_uninstallation "$PM"
fi
echo
echo -e "${GREEN}=========================================${NC}"
echo -e "${GREEN}β
Uninstallation completed!${NC}"
echo -e "${GREEN}=========================================${NC}"
echo
echo "DomainShield has been uninstalled."
echo "The script files in the current directory remain intact."
echo
echo "To reinstall, run: ./install.sh"
}
# Help function
show_help() {
echo "DomainShield Uninstaller"
echo ""
echo "This script removes DomainShield symlink and optionally uninstalls tools."
echo ""
echo "Usage: ./Uninstall.sh"
echo ""
echo "The script will:"
echo " 1. Remove the domainshield symlink from /usr/local/bin/"
echo " 2. Ask if you want to uninstall any tools"
echo " 3. Provide options to uninstall specific tools or all tools"
echo ""
echo "Available tools to uninstall:"
echo " - dnsutils/bind-utils (dig, nslookup)"
echo " - whois"
echo " - curl"
echo " - openssl"
echo " - netcat"
echo ""
echo "Note: The DomainShield script files will remain in the current directory."
}
# Parse command line arguments
case "${1:-}" in
-h|--help)
show_help
exit 0
;;
*)
main
;;
esac