-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathuninstall.sh
More file actions
137 lines (123 loc) · 4.38 KB
/
uninstall.sh
File metadata and controls
137 lines (123 loc) · 4.38 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
#!/bin/bash
# Aliens Eye - Uninstall Script
# This script uninstalls Aliens Eye from both Linux and Termux environments
# Colors for terminal output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print banner
echo -e "${BLUE}╔═══════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ ${RED}Aliens Eye Uninstaller${BLUE} ║${NC}"
echo -e "${BLUE}╚═══════════════════════════════════════════╝${NC}"
echo
# Detect environment (Linux or Termux)
if [ -d "/data/data/com.termux" ]; then
echo -e "${YELLOW}Termux environment detected${NC}"
# Termux paths
PREFIX="/data/data/com.termux/files/usr"
BIN_DIR="${PREFIX}/bin"
CONFIG_DIR="${PREFIX}/etc/aliens_eye"
REQUIRES_ROOT=false
else
echo -e "${YELLOW}Linux environment detected${NC}"
# Standard Linux paths
PREFIX="/usr/local"
BIN_DIR="${PREFIX}/bin"
ALT_BIN_DIR="/usr/bin"
CONFIG_DIR="/etc/aliens_eye"
REQUIRES_ROOT=true
# Check for root permissions on Linux
if [[ $(id -u) -ne 0 && "$REQUIRES_ROOT" = true ]]; then
echo -e "${YELLOW}Root privileges are required for uninstallation on Linux.${NC}"
echo -e "${YELLOW}Elevating privileges...${NC}"
exec sudo bash "$0" "$@"
exit $?
fi
fi
# Function to remove files with status reporting
remove_file() {
local file=$1
if [ -e "$file" ]; then
rm -f "$file"
if [ $? -eq 0 ]; then
echo -e " ${GREEN}✓${NC} Removed: $file"
return 0
else
echo -e " ${RED}✗${NC} Failed to remove: $file"
return 1
fi
else
echo -e " ${YELLOW}!${NC} Not found: $file"
return 0
fi
}
# Function to remove directory with status reporting
remove_dir() {
local dir=$1
if [ -d "$dir" ]; then
rm -rf "$dir"
if [ $? -eq 0 ]; then
echo -e " ${GREEN}✓${NC} Removed directory: $dir"
return 0
else
echo -e " ${RED}✗${NC} Failed to remove directory: $dir"
return 1
fi
else
echo -e " ${YELLOW}!${NC} Directory not found: $dir"
return 0
fi
}
# Confirmation prompt
echo -e "${YELLOW}This will uninstall Aliens Eye from your system.${NC}"
echo -e "${YELLOW}Are you sure you want to continue? [y/N]${NC}"
read -r response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo -e "${YELLOW}Uninstallation cancelled.${NC}"
exit 0
fi
# Uninstall files
echo -e "\n${GREEN}Removing Aliens Eye files...${NC}"
# Remove binaries
remove_file "${BIN_DIR}/aliens_eye"
# Check alternative binary location for Linux
if [ "$REQUIRES_ROOT" = true ] && [ -e "${ALT_BIN_DIR}/aliens_eye" ]; then
remove_file "${ALT_BIN_DIR}/aliens_eye"
fi
# Remove symlinks to configuration
remove_file "${BIN_DIR}/sites.json"
if [ "$REQUIRES_ROOT" = true ] && [ -e "${ALT_BIN_DIR}/sites.json" ]; then
remove_file "${ALT_BIN_DIR}/sites.json"
fi
# Remove configuration directory
echo -e "\n${GREEN}Removing configuration files...${NC}"
remove_dir "${CONFIG_DIR}"
# Additional cleanup - remove any leftover files
echo -e "\n${GREEN}Checking for leftover files...${NC}"
if [ "$REQUIRES_ROOT" = true ]; then
find /tmp -name "aliens_eye_*" -type f -exec rm -f {} \; 2>/dev/null
if [ $? -eq 0 ]; then
echo -e " ${GREEN}✓${NC} Cleaned temporary files"
else
echo -e " ${YELLOW}!${NC} No temporary files found or couldn't access /tmp"
fi
fi
# Check for success
if [ ! -e "${BIN_DIR}/aliens_eye" ] && [ ! -d "${CONFIG_DIR}" ]; then
if [ "$REQUIRES_ROOT" = true ] && [ -e "${ALT_BIN_DIR}/aliens_eye" ]; then
echo -e "\n${RED}Partial uninstallation. Some files may remain in ${ALT_BIN_DIR}.${NC}"
exit 1
else
echo -e "\n${GREEN}✓ Aliens Eye has been successfully uninstalled from your system!${NC}"
if [ "$REQUIRES_ROOT" = true ]; then
echo -e "${YELLOW}You may need to restart your terminal for changes to take effect.${NC}"
fi
exit 0
fi
else
echo -e "\n${RED}✗ Uninstallation may be incomplete. Some files could not be removed.${NC}"
echo -e "${YELLOW}You may need to manually remove remaining files.${NC}"
exit 1
fi