forked from vchelaru/Gum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_gum.sh
More file actions
executable file
·137 lines (116 loc) · 5.03 KB
/
remove_gum.sh
File metadata and controls
executable file
·137 lines (116 loc) · 5.03 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
#!/bin/bash
################################################################################
### Check if wine-stable is installed
################################################################################
SCRIPT_VERSION="2026.02.16"
# Determine the wine prefix: CLI arg > read from gum launcher > default
GUM_WINE_PREFIX_PATH="$HOME/.wine_gum_dotnet8"
if [ -n "$1" ]; then
GUM_WINE_PREFIX_PATH="$1"
elif [ -f ~/bin/gum ]; then
FOUND=$(grep 'WINEPREFIX=' ~/bin/gum | head -1 | sed 's/.*WINEPREFIX="//' | sed 's/".*//')
if [ -n "$FOUND" ]; then
GUM_WINE_PREFIX_PATH="$FOUND"
fi
fi
echo "GUM removal script (v$SCRIPT_VERSION)"
echo "This will attempt to remove the automated install of wine, winetricks, and GUM."
echo "If you did not install GUM using the setup_gum_linux.sh or setup_gum_mac.sh script, please do not run this script !!!!"
echo "Using WINE PREFIX: $GUM_WINE_PREFIX_PATH"
echo ""
read -p "Do you wish to continue? (y/n): " choice
case "$choice" in
y|Y ) echo "Continuing...";;
n|N ) echo "Exiting."; exit 0;;
* ) echo "Invalid option. Exiting."; exit 1;;
esac
if ! rm -rf "$GUM_WINE_PREFIX_PATH"; then
echo "ERROR: Failed to remove wine folder $GUM_WINE_PREFIX_PATH"
exit 1
fi
echo "Removed wine folder $GUM_WINE_PREFIX_PATH"
################################################################################
### Remove the gum launcher script
################################################################################
if [ -f ~/bin/gum ]; then
if ! rm -f ~/bin/gum; then
echo "ERROR: Failed to remove ~/bin/gum launcher script"
exit 1
fi
echo "Removed ~/bin/gum launcher script"
fi
# Uninstall depending on the OS
DISTRO=$( (lsb_release -si 2>/dev/null || grep '^ID=' /etc/os-release 2>/dev/null || echo "${OSTYPE//[0-9\.]/}" 2>/dev/null || name) | cut -d= -f2 | tr -d '"' | tr '[:upper:]' '[:lower:]')
case "$DISTRO" in
ubuntu|linuxmint)
sudo apt remove --purge winetricks -y || echo "ERROR: Failed to uninstall winetricks"
sudo apt remove --purge winehq-* wine-* -y || echo "ERROR: Failed to uninstall wine"
sudo rm -f /etc/apt/keyrings/winehq-archive.key 2>/dev/null || true
sudo rm -f /etc/apt/sources.list.d/winehq-*.sources 2>/dev/null || true
;;
fedora|nobara)
sudo dnf remove winetricks || echo "ERROR: Failed to uninstall winetricks"
sudo dnf remove winehq-* wine-* || echo "ERROR: Failed to uninstall wine"
;;
darwin)
brew uninstall winetricks || echo "ERROR: Failed to uninstall winetricks"
brew uninstall --cask wine-stable || echo "ERROR: Failed to uninstall wine-stable"
echo "BREW will not be uninstalled, if you do not want that, you can uninstall that manually"
;;
*)
echo "Unsupported or unknown distribution: $DISTRO"
echo "Please uninstall wine manually!"
echo "https://duckduckgo.com/?t=h_&q=Insert+Your+Linux+Distro+Here+How+To+Install+Wine"
exit 1
;;
esac
# macOS (BSD) sed requires -i '' while GNU sed uses -i
if [ "$DISTRO" = "darwin" ]; then
SED_INPLACE=(sed -i '')
else
SED_INPLACE=(sed -i)
fi
################################################################################
### Clean up PATH entries added by setup script (safe: only removes exact lines)
################################################################################
if [ -f ~/.bashrc ] && grep -q 'export PATH="$HOME/bin:$PATH"' ~/.bashrc 2>/dev/null; then
if ! "${SED_INPLACE[@]}" '\|export PATH="$HOME/bin:$PATH"|d' ~/.bashrc; then
echo "ERROR: Failed to update ~/.bashrc"
exit 1
fi
echo "Removed PATH entry from ~/.bashrc"
fi
if [ -f ~/.zshrc ] && grep -q 'export PATH="$HOME/bin:$PATH"' ~/.zshrc 2>/dev/null; then
if ! "${SED_INPLACE[@]}" '\|export PATH="$HOME/bin:$PATH"|d' ~/.zshrc; then
echo "ERROR: Failed to update ~/.zshrc"
exit 1
fi
echo "Removed PATH entry from ~/.zshrc"
fi
if [ -f ~/.config/fish/config.fish ] && grep -q 'set -x PATH $HOME/bin $PATH' ~/.config/fish/config.fish 2>/dev/null; then
if ! "${SED_INPLACE[@]}" '\|set -x PATH $HOME/bin $PATH|d' ~/.config/fish/config.fish; then
echo "ERROR: Failed to update config.fish"
exit 1
fi
echo "Removed PATH entry from config.fish"
fi
################################################################################
### Finished
################################################################################
echo -e "\nFinished! Wine and GUM have been removed from your system."
case "$DISTRO" in
ubuntu|linuxmint)
echo "Leftover installers may be purged with: sudo apt autoremove && sudo apt clean"
;;
fedora|nobara)
echo "Leftover installers may be purged with: sudo dnf autoremove"
;;
darwin)
echo "Leftover installers may be purged with: brew cleanup"
;;
esac
if [ "$DISTRO" = "darwin" ]; then
echo "If you wish to reinstall GUM, please run setup_gum_mac.sh again."
else
echo "If you wish to reinstall GUM, please run setup_gum_linux.sh again."
fi