93
by Tony George
Updated install script; Added uninstaller |
1 |
#!/bin/bash
|
2 |
||
3 |
app_name='timeshift' |
|
4 |
app_fullname='Timeshift' |
|
5 |
||
6 |
Reset='\e[0m' |
|
7 |
Red='\e[1;31m' |
|
8 |
Green='\e[1;32m' |
|
9 |
Yellow='\e[1;33m' |
|
10 |
||
11 |
CHECK_COLOR_SUPPORT() { |
|
12 |
colors=`tput colors` |
|
13 |
if [ $colors -gt 1 ]; then |
|
14 |
COLORS_SUPPORTED=0 |
|
15 |
else
|
|
16 |
COLORS_SUPPORTED=1 |
|
17 |
fi
|
|
18 |
}
|
|
19 |
||
20 |
MSG_INFO() { |
|
96
by Tony George
Updated installer |
21 |
add_newline='' |
22 |
if [ "$2" == 0 ]; then |
|
23 |
add_newline='-n' |
|
24 |
fi
|
|
25 |
||
93
by Tony George
Updated install script; Added uninstaller |
26 |
if [ $COLORS_SUPPORTED -eq 0 ]; then |
96
by Tony George
Updated installer |
27 |
echo -e ${add_newline} "[${Yellow}*${Reset}] ${Green}$1${Reset}" |
93
by Tony George
Updated install script; Added uninstaller |
28 |
else
|
96
by Tony George
Updated installer |
29 |
echo -e ${add_newline} "[*] $1" |
93
by Tony George
Updated install script; Added uninstaller |
30 |
fi
|
31 |
}
|
|
32 |
||
33 |
MSG_WARNING() { |
|
96
by Tony George
Updated installer |
34 |
add_newline='' |
35 |
if [ "$2" == 0 ]; then |
|
36 |
add_newline='-n' |
|
37 |
fi
|
|
178
by Tony George
v1.7.4 |
38 |
|
93
by Tony George
Updated install script; Added uninstaller |
39 |
if [ $COLORS_SUPPORTED -eq 0 ]; then |
96
by Tony George
Updated installer |
40 |
echo -e ${add_newline} "[${Red}!${Reset}] ${Yellow}$1${Reset}" |
93
by Tony George
Updated install script; Added uninstaller |
41 |
else
|
96
by Tony George
Updated installer |
42 |
echo -e ${add_newline} "[!] $1" |
93
by Tony George
Updated install script; Added uninstaller |
43 |
fi
|
44 |
}
|
|
45 |
||
46 |
MSG_ERROR() { |
|
96
by Tony George
Updated installer |
47 |
add_newline='' |
48 |
if [ "$2" == 0 ]; then |
|
49 |
add_newline='-n' |
|
50 |
fi
|
|
178
by Tony George
v1.7.4 |
51 |
|
93
by Tony George
Updated install script; Added uninstaller |
52 |
if [ $COLORS_SUPPORTED -eq 0 ]; then |
96
by Tony George
Updated installer |
53 |
echo -e ${add_newline} "[${Red}X${Reset}] ${Yellow}$1${Reset}" |
93
by Tony George
Updated install script; Added uninstaller |
54 |
else
|
96
by Tony George
Updated installer |
55 |
echo -e ${add_newline} "[X] $1" |
93
by Tony George
Updated install script; Added uninstaller |
56 |
fi
|
57 |
}
|
|
58 |
||
59 |
CD_PUSH() { |
|
60 |
cd_backup=`pwd` |
|
61 |
}
|
|
62 |
||
63 |
CD_POP() { |
|
64 |
if [ ! -z "${cd_backup}" ]; then |
|
65 |
cd "${cd_backup}" |
|
66 |
fi
|
|
67 |
}
|
|
68 |
||
69 |
EXIT(){
|
|
70 |
CD_POP |
|
71 |
exit $1 |
|
72 |
}
|
|
73 |
||
74 |
WAIT_FOR_INPUT() { |
|
75 |
echo "" |
|
76 |
echo "Press any key to exit..." |
|
77 |
read dummy
|
|
78 |
}
|
|
79 |
||
80 |
GET_SCRIPT_PATH(){
|
|
81 |
SCRIPTPATH="$(cd "$(dirname "$0")" && pwd)" |
|
82 |
SCRIPTNAME=`basename $0` |
|
83 |
}
|
|
84 |
||
85 |
RUN_AS_ADMIN() { |
|
86 |
if [ ! `id -u` -eq 0 ]; then |
|
87 |
GET_SCRIPT_PATH |
|
88 |
if command -v sudo >/dev/null 2>&1; then |
|
89 |
sudo "${SCRIPTPATH}/${SCRIPTNAME}" |
|
90 |
EXIT $?
|
|
91 |
elif command -v su >/dev/null 2>&1; then |
|
92 |
su -c "${SCRIPTPATH}/${SCRIPTNAME}" |
|
93 |
EXIT $?
|
|
94 |
else
|
|
95 |
echo "" |
|
96 |
MSG_ERROR "** Uninstaller must be run as Admin (using 'sudo' or 'su') **"
|
|
97 |
echo "" |
|
98 |
EXIT 1
|
|
99 |
fi
|
|
100 |
fi
|
|
101 |
}
|
|
102 |
||
103 |
CD_PUSH |
|
104 |
CHECK_COLOR_SUPPORT |
|
105 |
RUN_AS_ADMIN |
|
106 |
||
107 |
if [ ! -z "${app_name}" ]; then |
|
108 |
rm -f "/usr/bin/${app_name}" |
|
94
by Tony George
Updated build and install scripts |
109 |
rm -f "/usr/bin/${app_name}-uninstall" |
93
by Tony George
Updated install script; Added uninstaller |
110 |
rm -f "/usr/share/applications/${app_name}.desktop" |
111 |
rm -f "/usr/share/pixmaps/${app_name}.png" |
|
112 |
rm -rf "/usr/share/${app_name}" |
|
113 |
rm -rf "/usr/share/doc/${app_name}" |
|
94
by Tony George
Updated build and install scripts |
114 |
rm -f /usr/share/locale/*/LC_MESSAGES/${app_name}.mo |
178
by Tony George
v1.7.4 |
115 |
|
97
by Tony George
Updated installer |
116 |
if [ -d /timeshift ]; then |
117 |
remove_backups=n |
|
118 |
MSG_INFO "Remove backups on system partition? (y/n):" "0" |
|
119 |
read remove_backups
|
|
120 |
if [ "$remove_backups" == "" ]; then |
|
121 |
remove_backups=n |
|
122 |
fi
|
|
178
by Tony George
v1.7.4 |
123 |
|
97
by Tony George
Updated installer |
124 |
if [ "$remove_backups" == "y" ]; then |
125 |
MSG_INFO "Freeing disk space..."
|
|
126 |
echo "" |
|
127 |
rm -rf "/timeshift"
|
|
128 |
fi
|
|
95
by Tony George
Prompt user to delete backups in uninstall script |
129 |
fi
|
93
by Tony George
Updated install script; Added uninstaller |
130 |
fi
|
131 |
||
132 |
if [ $? -eq 0 ]; then |
|
133 |
echo "${app_fullname} was uninstalled successfully." |
|
134 |
EXIT 0
|
|
135 |
else
|
|
136 |
echo "Uninstalled completed (some files could not be removed)" |
|
137 |
EXIT 1
|
|
138 |
fi
|
|
139 |
||
140 |
CD_POP |