-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.sh
executable file
·69 lines (57 loc) · 1.71 KB
/
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
#!/bin/bash
BASE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
function confirm_uninstall(){
while :; do
read -p '>>> do you really want to uninstall pcli and remove its files? y/n ' answer
case $answer in
[Yy]* ) return 0;;
[Nn]* ) return 1;;
* ) echo '>>> please answer y or n';;
esac
done
}
function remove_folders(){
rm -r ~/.ssh/pcli &> /dev/null
sudo rm -r /etc/pcli/ &> /dev/null
sudo rm -r /var/log/pcli &> /dev/null
FOLDERS_ARRAY=( ~/.ssh/pcli/ /etc/pcli/ /var/log/pcli/ )
for folder in "${FOLDERS_ARRAY[@]}"; do
if [ ! -d "$folder" ]; then
echo ">>> $folder deleted"
else
echo ">>> error deleting $folder"
fi
done
}
function remove_pipenv_env(){
grep -v "$(cd $BASE_PATH; pipenv --venv)" ~/.bashrc > ~/.bashrc_tmp
mv ~/.bashrc_tmp ~/.bashrc &> /dev/null
rm ~/.bashrc_tmp &> /dev/null
source ~/.bashrc
rm -r "$(cd $BASE_PATH; pipenv --venv)" &> /dev/null
echo '>>> bashrc edited'
echo '>>> pcli removed from path'
}
function verify_uninstall(){
pcli &> /dev/null
if [ ! $? == 127 ]; then
echo '>>> error while uninstalling'
return 1
fi
}
function main(){
if ! confirm_uninstall; then
return 1
fi
remove_folders
remove_pipenv_env
if ! verify_uninstall; then
return 1
fi
echo; echo;
echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
echo '>>> uninstall finished!'
echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
echo; echo;
}
main