forked from yorukot/superfile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
151 lines (137 loc) · 5.43 KB
/
Copy pathuninstall.sh
File metadata and controls
151 lines (137 loc) · 5.43 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
#!/bin/bash
green='\033[0;32m'
red='\033[0;31m'
yellow='\033[0;33m'
blue='\033[0;34m'
purple='\033[0;35m'
cyan='\033[0;36m'
white='\033[0;37m'
bright_red='\033[1;31m'
bright_green='\033[1;32m'
bright_yellow='\033[1;33m'
bright_blue='\033[1;34m'
bright_purple='\033[1;35m'
bright_cyan='\033[1;36m'
bright_white='\033[1;37m'
nc='\033[0m' # No Color
echo -e '
\033[0;31m ______ __ __
\033[1;31m / \ / |/ |
\033[0;33m _______ __ __ ______ ______ ______ /$$$$$$ |$$/ $$ | ______
\033[1;33m / |/ | / | / \ / \ / \ $$ |_ $$/ / |$$ | / \
\033[0;32m/$$$$$$$/ $$ | $$ |/$$$$$$ |/$$$$$$ |/$$$$$$ |$$ | $$ |$$ |/$$$$$$ |
\033[1;32m$$ \ $$ | $$ |$$ | $$ |$$ $$ |$$ | $$/ $$$$/ $$ |$$ |$$ $$ |
\033[0;34m $$$$$$ |$$ \__$$ |$$ |__$$ |$$$$$$$$/ $$ | $$ | $$ |$$ |$$$$$$$$/
\033[1;34m/ $$/ $$ $$/ $$ $$/ $$ |$$ | $$ | $$ |$$ |$$ |
\033[0;35m$$$$$$$/ $$$$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$$/
\033[1;35m $$ |
\033[0;31m $$ |
\033[1;31m $$/
'
found=0
failed=0
if [ -z "${HOME:-}" ] || [ "$HOME" = "/" ]; then
echo -e "${red}❌ Refusing to run uninstall with an unsafe HOME value.${nc}"
exit 1
fi
# Resolve XDG dirs, falling back to spec-defined defaults
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
# Remove binary from /usr/local/bin
if [ -f /usr/local/bin/spf ]; then
found=1
echo -e "${bright_yellow}Removing ${cyan}/usr/local/bin/spf${bright_yellow}...${nc}"
if ! sudo rm /usr/local/bin/spf; then
echo -e "${red}❌ Failed to remove ${white}/usr/local/bin/spf${red}. Do you have sudo permissions?${nc}"
failed=1
else
echo -e "${bright_green}✔ Removed ${white}/usr/local/bin/spf${nc}"
fi
fi
# Remove binary from ~/.local/bin
if [ -f "$HOME/.local/bin/spf" ]; then
found=1
echo -e "${bright_yellow}Removing ${cyan}~/.local/bin/spf${bright_yellow}...${nc}"
if ! rm "$HOME/.local/bin/spf"; then
echo -e "${red}❌ Failed to remove ${white}~/.local/bin/spf${nc}"
failed=1
else
echo -e "${bright_green}✔ Removed ${white}~/.local/bin/spf${nc}"
fi
fi
# Remove config directory
if [ -d "$XDG_CONFIG_HOME/superfile" ]; then
found=1
echo -e "${bright_yellow}Removing ${cyan}$XDG_CONFIG_HOME/superfile${bright_yellow}...${nc}"
if ! rm -rf "$XDG_CONFIG_HOME/superfile"; then
echo -e "${red}❌ Failed to remove ${white}$XDG_CONFIG_HOME/superfile${nc}"
failed=1
else
echo -e "${bright_green}✔ Removed ${white}$XDG_CONFIG_HOME/superfile${nc}"
fi
fi
# Remove data directory
if [ -d "$XDG_DATA_HOME/superfile" ]; then
found=1
echo -e "${bright_yellow}Removing ${cyan}$XDG_DATA_HOME/superfile${bright_yellow}...${nc}"
if ! rm -rf "$XDG_DATA_HOME/superfile"; then
echo -e "${red}❌ Failed to remove ${white}$XDG_DATA_HOME/superfile${nc}"
failed=1
else
echo -e "${bright_green}✔ Removed ${white}$XDG_DATA_HOME/superfile${nc}"
fi
fi
# Remove cache directory
if [ -d "$XDG_CACHE_HOME/superfile" ]; then
found=1
echo -e "${bright_yellow}Removing ${cyan}$XDG_CACHE_HOME/superfile${bright_yellow}...${nc}"
if ! rm -rf "$XDG_CACHE_HOME/superfile"; then
echo -e "${red}❌ Failed to remove ${white}$XDG_CACHE_HOME/superfile${nc}"
failed=1
else
echo -e "${bright_green}✔ Removed ${white}$XDG_CACHE_HOME/superfile${nc}"
fi
fi
# Remove state directory
if [ -d "$XDG_STATE_HOME/superfile" ]; then
found=1
echo -e "${bright_yellow}Removing ${cyan}$XDG_STATE_HOME/superfile${bright_yellow}...${nc}"
if ! rm -rf "$XDG_STATE_HOME/superfile"; then
echo -e "${red}❌ Failed to remove ${white}$XDG_STATE_HOME/superfile${nc}"
failed=1
else
echo -e "${bright_green}✔ Removed ${white}$XDG_STATE_HOME/superfile${nc}"
fi
fi
# Remove Application Support directory (macOS)
if [ -d "$HOME/Library/Application Support/superfile" ]; then
found=1
echo -e "${bright_yellow}Removing ${cyan}~/Library/Application Support/superfile${bright_yellow}...${nc}"
if ! rm -rf "$HOME/Library/Application Support/superfile"; then
echo -e "${red}❌ Failed to remove ${white}~/Library/Application Support/superfile${nc}"
failed=1
else
echo -e "${bright_green}✔ Removed ${white}~/Library/Application Support/superfile${nc}"
fi
fi
# Remove cache directory (macOS)
if [ -d "$HOME/Library/Caches/superfile" ]; then
found=1
echo -e "${bright_yellow}Removing ${cyan}~/Library/Caches/superfile${bright_yellow}...${nc}"
if ! rm -rf "$HOME/Library/Caches/superfile"; then
echo -e "${red}❌ Failed to remove ${white}~/Library/Caches/superfile${nc}"
failed=1
else
echo -e "${bright_green}✔ Removed ${white}~/Library/Caches/superfile${nc}"
fi
fi
if [ "$found" -eq 0 ]; then
echo -e "${yellow}No superfile installation found. Nothing to remove.${nc}"
elif [ "$failed" -eq 1 ]; then
echo -e "\n${red}⚠ Uninstall completed with errors. Please review the messages above.${nc}"
exit 1
else
echo -e "\n👋 ${bright_green}superfile has been uninstalled.${nc}"
fi