-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall
executable file
·62 lines (46 loc) · 1.29 KB
/
uninstall
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
#!/bin/bash
# Author : Gcaufy
# Date : 2020/03/01
set -e
PREFIX="${HOME}/.sshman"
# compatible sed in MacOS and Linux
function sedi () {
OS=$(uname)
if [[ "$OS" == "Darwin" ]]; then
sed -i '' "$1" "$2"
else
sed -i "$1" "$2"
fi
}
function remove_alias() {
local _alias
local _rowno
_alias="alias s=\"'${HOME}/.sshman/sshman'\""
echo "Remove from $1:"
_rowno=$(grep -n "$_alias" "$1" | cut -d : -f 1)
if [[ -z $_rowno ]]; then
echo " - Nothing found"
else
sedi "${_rowno}d" "$1"
echo " - Removed"
fi
}
function uninstall() {
for shell in bash zsh; do
remove_alias ~/.${shell}rc
done
local _db
_db="${PREFIX}/servers.db"
if [[ -f "$_db" ]]; then
echo -e "\n"
echo -e "***********************!!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! *****************************"
echo -e "*****ALL THIS SSH CONFIG REMOVED, MARE SURE YOU RECORD IT, OTHERWISE IT WILL BE GONE FOREVER *****"
echo -e "**************************************************************************************************"
cat "$_db"
echo -e "***********************!!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! *****************************"
fi
rm -rf "${PREFIX}"
echo -e "\n"
echo -e " Unstall finished. clean as before."
}
uninstall