-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelm_uninstall.sh
128 lines (113 loc) · 3.42 KB
/
helm_uninstall.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
#!/bin/bash
helm_ascii="
:#+
*##:
:=- ###- :==
.###- .::*##-:. +##+
:###=-+*####***####*=:.###=
*###*=:. .:=####*.
:*#*-. :=##+.
... ...
*#+ ##- -#####= -## -#= :+*
##* .##= -##... -## -###=.:*###
########= -#####: -## -##+###**##
##*...##= -##. -##:... -## =: +##
##* ##= -#####= -#####+ -## +##
-*#*: =*#+.
.*###+-. :-*###*.
.*##+=*####*****####+-:###=
.###= .:--*##=-:. .*##+
:+= ###- :++
*##:
:#*
"
init_message(){
echo -e "\033[38;5;4m$helm_ascii\033[38;5;0m "
}
detect_os() {
local OS=""
if [ -f /etc/os-release ]; then
. /etc/os-release
if [[ $ID_LIKE == *"rhel"* || $ID == "rhel" ]]; then
OS="Red Hat"
elif [[ $ID == "ubuntu" || $ID_LIKE == *"debian"* ]]; then
OS="Linux"
else
OS="Linux"
fi
elif [ "$(uname)" == "Darwin" ]; then
OS="Mac"
else
OS="Unknown"
fi
echo "$OS"
}
uninstall_helm_in_mac(){
echo "Uninstalling Helm on macOS..."
brew uninstall helm
if [ $? -eq 0 ]; then
echo "Helm successfully uninstalled on macOS!"
else
echo "Error occurred while uninstalling Helm on macOS."
fi
}
uninstall_helm_in_linux(){
echo "Uninstalling Helm on Ubuntu/Debian..."
sudo apt-get remove -y helm
sudo rm -rf /usr/share/keyrings/helm-archive-keyring.gpg
if [ $? -eq 0 ]; then
echo "Helm successfully uninstalled on Ubuntu/Debian!"
else
echo "Error occurred while uninstalling Helm on Ubuntu/Debian."
fi
}
uninstall_helm_in_redhat(){
echo "Uninstalling Helm on Red Hat/CentOS..."
sudo yum remove -y helm
sudo rm -rf /usr/share/keyrings/helm-archive-keyring.gpg
if [ $? -eq 0 ]; then
echo "Helm successfully uninstalled on Red Hat/CentOS!"
else
echo "Error occurred while uninstalling Helm on Red Hat/CentOS."
fi
}
uninstall_helm_in_unknown(){
echo "Manual removal required for unsupported OS."
echo "Do you want to remove the binary file manually? (Y/N)"
read -p "> " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo "Removing Helm binary..."
sudo rm -f /usr/local/bin/helm
if [ $? -eq 0 ]; then
echo "Helm binary successfully removed!"
else
echo "Error occurred while removing Helm binary."
fi
else
echo "Uninstallation canceled for unsupported OS."
fi
}
# Main script execution
init_message
echo "Helm Uninstallation Script"
OS=$(detect_os)
echo "Detected OS: $OS"
read -p "Do you want to uninstall Helm? (Y/N): " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
case "$OS" in
"Mac")
uninstall_helm_in_mac
;;
"Linux")
uninstall_helm_in_linux
;;
"Red Hat")
uninstall_helm_in_redhat
;;
*)
uninstall_helm_in_unknown
;;
esac
else
echo "Uninstallation canceled."
fi