-
Notifications
You must be signed in to change notification settings - Fork 3
/
uninstall
executable file
·86 lines (70 loc) · 2.03 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
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
#!/usr/bin/env bash
shopt -s expand_aliases
set -e
# set up command line parsing via getopts
# Usage info
show_help() {
cat << EOF
Usage: ${0##*/} [-cd]
Remove all traces of Jupyter.app
-h Display this help and exit.
-d Dry run. For debug purposes, echo commands instead of running them.
-i Always ask for confirmation before deleting existing files
EOF
}
# Initialize our own variables:
dryrun=
confirm=
OPTIND=1
# Resetting OPTIND is necessary if getopts was used previously in the script.
# It is a good idea to make OPTIND local if you process options in a function.
while getopts hdir opt; do
case $opt in
h) show_help
exit 0
;;
d) dryrun=-d
;;
i) confirm=-i
;;
*) show_help >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))" # Discard the options and sentinel --
# define the dryrun echo command as appropriate
alias dryecho=
if [ "$dryrun" = "-d" ]; then
alias dryecho='echo'
fi
cleanup() {
pth=$1
msg=$2
if [ -e "$pth" -o "$dryrun" = "-d" ]; then
printf "${msg}"
if [ "$confirm" = "-i" -a "$dryrun" != "-d" ]; then
read -p "remove ${pth}? [y/n]: " -r INPUT
if [ "${INPUT:0:1}" = y -o "${INPUT:0:1}" = Y ]; then
rm -rf "${pth}"
printf "removed ${pth}\n\n"
else
printf "skipping\n\n"
fi
else
dryecho rm -rf "${pth}"
printf "removed ${pth}\n\n"
fi
fi
}
# get some user-defined and project-wide vars
reldir=$(dirname "$(stat -f "$0")")
source "${reldir}"/resource/globals
# remove the app
cleanup "${ABS_APP_PATH}" "cleaning up existing app...\n"
# remove the user-data-dir
cleanup "${ABS_APP_SUPPORT_PATH}" "cleaning up existing user-data-dir...\n"
# remove the app's cache
cleanup "${ABS_CACHE_PATH}" "cleaning up existing cache...\n"
# remove the app's preferences dir
cleanup "${ABS_PREFERENCES_PATH}" "cleaning up existing preferences file...\n"