This repository has been archived by the owner on Oct 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathuninstall.sh
executable file
·94 lines (64 loc) · 2.17 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
: '
%file uninstall.sh
%author Sam Freeside (@snovvcrash) <snovvcrash@protonmail[.]ch>
%date 2018-05-28
%brief usbrip uninstaller.
%license
Copyright (C) 2020 Sam Freeside
This file is part of usbrip.
usbrip is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
usbrip is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with usbrip. If not, see <http://www.gnu.org/licenses/>.
%endlicense
'
# Usage: sudo bash installers/uninstall.sh [-a/--all]
# --------------- Check for root privileges ----------------
if [[ $EUID -ne 0 ]]; then
/usr/bin/printf "${R}>>>>${NC} Please run as root:\nsudo %s [-a/--all]\n" "${0}"
exit 1
fi
# ----------------------- Constants ------------------------
if [[ -z "${SUDO_USER}" ]]; then
SUDO_USER="root"
fi
USER_HOME=`getent passwd ${SUDO_USER} | cut -d: -f6`
CONFIG="${USER_HOME}/.config/usbrip"
OPT="/opt/usbrip"
VAR_OPT="/var/opt/usbrip"
SYMLINK="/usr/local/bin/usbrip"
G="\033[1;32m" # GREEN
R="\033[1;31m" # RED
NC="\033[0m" # NO COLOR
# ----------------------- Functions ------------------------
remove_directory() {
if /bin/rm -r "$1" 2> /dev/null; then
/usr/bin/printf "${G}>>>>${NC} Removed directory: '$1'\n"
fi
}
# -------------------- Handle switches ---------------------
if [[ "$1" == "-a" ]] || [[ "$1" == "--all" ]]; then
ALL=true
else
ALL=false
fi
# ------------------- Remove directories -------------------
# OPT
remove_directory "${OPT}"
# VAR_OPT
remove_directory "${VAR_OPT}"
# CONFIG
remove_directory "${CONFIG}"
# --------------------- Remove symlink ---------------------
if /bin/rm "${SYMLINK}" 2> /dev/null; then
/usr/bin/printf "${G}>>>>${NC} Removed symlink: '${SYMLINK}'\n"
fi
# -------------------------- Done --------------------------
/usr/bin/printf "${G}>>>>${NC} Done.\n"