-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall
executable file
·51 lines (42 loc) · 1.43 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
#!/bin/bash
if [ -d "$(_clupath cli)" ]; then
echo ""
echo "Unmounting and removing all hosts..."
# Remove all hosts safely
clu removehost --all
# Remove the mounts directory
# This will only be possible if the directory is empty, in which case
# write permissions are already granted (see last lines of the
# removecluster subcommand)
rmdir ${CLUSTER_UTILS_MOUNTS}
fi
if [ ! -d "${CLUSTER_UTILS_MOUNTS}" ]; then
# Remove the activation script from the init file
# Get the init file
unamestr=`uname`
if [[ $SHELL == *"bash" ]]; then
if [[ "$unamestr" == 'Linux' ]]; then
DEFAULT_INIT="$HOME/.bashrc"
elif [[ "$unamestr" == 'Darwin' ]]; then
DEFAULT_INIT="$HOME/.bash_profile"
fi
elif [[ $SHELL == *"zsh" ]]; then
DEFAULT_INIT="$HOME/.zshrc"
fi
INIT_FILE=${INIT_FILE:-$DEFAULT_INIT}
startline="# Added by cluster-utils. Do not modify if you want automatic uninstall"
endline="# End of cluster-utils"
sed -i "/$startline/,/$endline/d" "${INIT_FILE}"
rm "${CLUSTER_UTILS_ROOT}/.installed"
echo ""
echo "Succesful uninstall!"
echo ""
else
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo " UNINSTALL ERROR: Some hosts are still mounted"
echo " even though we tried to automatically unmount them."
echo " Please manually unmount all of them and then remove the"
echo " mounts folder:"
echo " ${CLUSTER_UTILS_MOUNTS}"
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
fi