-
Notifications
You must be signed in to change notification settings - Fork 2
/
uninstall.sh
executable file
·69 lines (58 loc) · 1.58 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
#
# COLORS
#
C_S="\033[0;0m" # RESET
C_Y="\033[1;33m" # YELLOW
C_R="\033[1;31m" # RED
C_G="\033[1;32m" # GREEN
C_B="\033[1;34m" # BLUE
#
# UNINSTALL THE HOME FILES
#
droot="$PWD"
dhome="$HOME"
dold="${dhome}/.old/"
# check if it is installed
if [ ! -d "${dold}" ]
then
echo "No backup directory found. Did you remove '${dold}'?"
exit 1
fi
if [ -e "${dhome}/.environment" ]
then
$droot/common/bin/justify-left "Deleting environment file '.environment' ..." 70
rm "${dhome}/.environment" \
&& echo -e "$C_S[$C_G OK $C_S]" \
|| echo -e "$C_S[$C_R FAIL $C_S]"
fi
for wholefile in ${dold}/*
do
currentfile=$(basename $wholefile)
# if a symbolic link
if [ -h "${dhome}/.${currentfile}" ]
then
$droot/common/bin/justify-left "Removing symbolic link \".${currentfile}\" ..." 70
rm "${dhome}/.${currentfile}" \
&& echo -e "$C_S[$C_G OK $C_S]" \
|| echo -e "$C_S[$C_R FAIL $C_S]"
fi
if [ -e "${dhome}/.${currentfile}" ]
then
$droot/common/bin/justify-left "File \"${currentfile}\" is existing ... " 70
echo -e "$C_S[$C_R FAIL $C_S]"
echo -e "$C_R > Please locate the file in '${dold}' and change it manually $C_S"
else
$droot/common/bin/justify-left "Restoring backup of file \"${currentfile}\" ..." 70
mv "${dold}/${currentfile}" "${dhome}/.${currentfile}" \
&& echo -e "$C_S[$C_G OK $C_S]" \
|| echo -e "$C_S[$C_R FAIL $C_S]"
fi
done
if [ -d "${dold}" ]
then
$droot/common/bin/justify-left "Removing backup directory \"${dold}\" ..." 70
rmdir "${dold}" \
&& echo -e "$C_S[$C_G OK $C_S]" \
|| echo -e "$C_S[$C_R FAIL $C_S]"
fi