-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathuninstall.sh
executable file
·83 lines (74 loc) · 1.41 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
#!/bin/bash
# uninstall script for ClonePi
# last updated @ v1.6.2
#
# - deletes clonepi command script
# - copies config dir to /tmp
# - deletes config dir
#
# helper functions
#
doMsg()
{
# msg, type
case "$2" in
warn)
printf "WARNING: ${1}\n"
echo
;;
user-abort)
printf "User aborted: ${1}\n"
echo
exit 0
;;
error)
printf "ERROR: ${1}\n"
echo "Aborting!"
echo
exit 1
;;
esac
}
#
# config
#
INSTALL_DIR="/usr/local/sbin"
CONF_DIR="/etc/clonepi"
BAK_DIR="/tmp/clonepi-conf-bak"
# exit if not root
if [ `id -u` != 0 ]; then
doMsg "The clonepi uninstaller needs to be run as root" "error"
fi
#
# summarise and get user confirmation
#
echo
echo "This will remove clonepi and its config files from your system."
echo
read -p "Continue with uninstall (yes|no)? " UI < /dev/tty
if [ ! "$UI" = "y" -a ! "$UI" = "yes" ]; then
doMsg "uninstall not confirmed" "user-abort"
fi
#
# And uninstall
#
echo
if [ -f ${INSTALL_DIR}/clonepi ]; then
rm -f ${INSTALL_DIR}/clonepi
if [ "$?" = 0 ]; then
echo "Deleted ${INSTALL_DIR}/clonepi"
else
doMsg "could not delete ${INSTALL_DIR}/clonepi" "error"
fi
fi
if [ -d ${CONF_DIR} ]; then
rm -rf ${BAK_DIR} && mv ${CONF_DIR} ${BAK_DIR}
if [ "$?" = 0 ]; then
echo "Deleted ${CONF_DIR}"
echo "A copy of the ${CONF_DIR} config dir has been placed at ${BAK_DIR}"
echo
else
doMsg "could not delete ${CONF_DIR}" "error"
fi
fi
exit 0