-
Notifications
You must be signed in to change notification settings - Fork 2
/
uninstall
executable file
·49 lines (41 loc) · 1016 Bytes
/
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
#!/bin/bash
BIN_DIR='/usr/bin';
VAR_DIR='/var';
ETC_DIR='/etc';
LOGROTATE_DIR='/etc/logrotate.d';
for arg in "$@"; do
case "$arg" in
--bin-dir=*)
BIN_DIR="${arg#--bin-dir=}";
;;
--var-dir=*)
VAR_DIR="${arg#--var-dir=}";
;;
--etc-dir=*)
ETC_DIR="${arg#--etc-dir=}";
;;
--logrotate-dir=*)
LOGROTATE_DIR="${arg#--logrotate-dir=}";
;;
esac;
done;
if [ -f "${BIN_DIR}/mhealth" ]; then
echo "This will uninstall mhealth"
rm "${BIN_DIR}/mhealth";
rm -rf "${VAR_DIR}/mhealth";
rm "${ETC_DIR}/mhealth";
rm "${LOGROTATE_DIR}/mhealth";
rm -rf /var/log/mhealth
# Remove mhealth from root's crontab
crontab -l | tail -n+4 > /tmp/crontab.new
echo "" >> /tmp/crontab.new
sed -e "/mhealth/d" -i /tmp/crontab.new
crontab /tmp/crontab.new
rm /tmp/crontab.new
sed -e "/mhealth/d" -i /etc/bash/bashrc
sed -e "/mhealth/d" -i /etc/conf.d/local.start
echo "Uninstallation completed. "
else
echo "!!! mhealth utility not installed. Please install before uninstalling"
exit 1;
fi;