forked from wmbusmeters/wmbusmeters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·84 lines (70 loc) · 2.06 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
#!/bin/bash
if [ ! -d "$1" ]
then
echo Usage: uninstall.sh [root_dir] [--purge]
exit 1
fi
ROOT="${1%/}"
if [ "$2" = "--purge" ]
then
echo Removing config files.
if [ -f "$ROOT"/etc/wmbusmeters.conf ]
then
rm "$ROOT"/etc/wmbusmeters.conf
echo conf file: removed "$ROOT"/etc/wmbusmeters.conf
fi
if [ -d "$ROOT"/etc/wmbusmeters.d ]
then
rm -rf "$ROOT"/etc/wmbusmeters.d
echo conf dir: removed "$ROOT"/etc/wmbusmeters.d
fi
if [ -d "$ROOT"/var/log/wmbusmeters/ ]
then
rm -rf "$ROOT"/var/log/wmbusmeters/
echo log dir: removed "$ROOT"/var/log/wmbusmeters/
fi
ID=$(id -u wmbusmeters 2>/dev/null)
if [ ! "$ID" = "" ]
then
userdel wmbusmeters
echo "user: removed wmbusmeters"
fi
if [ $(getent group wmbusmeters) ]
then
groupdel wmbusmeters
echo "group: removed wmbusmeters"
fi
else
echo "The option --purge was not supplied."
echo "Not removing: $ROOT/etc/wmbusmeters.conf"
echo "Not removing: $ROOT/etc/wmbusmeters.d"
ID=$(id -u wmbusmeters 2>/dev/null)
if [ ! "$ID" = "" ]
then
echo "Not removing user: wmbusmeters"
fi
if [ $(getent group wmbusmeters) ]
then
echo "Not removing group: wmbusmeters"
fi
fi
if [ -x "$ROOT"/usr/bin/wmbusmeters ] || [ -x "$ROOT"/usr/sbin/wmbusmeters ]
then
rm -f "$ROOT"/usr/bin/wmbusmeters "$ROOT"/usr/sbin/wmbusmetersd
echo binaries: removed "$ROOT"/usr/bin/wmbusmeters and "$ROOT"/usr/sbin/wmbusmetersd
fi
if [ -f "$ROOT"/usr/share/man/man1/wmbusmeters.1.gz ]
then
rm "$ROOT"/usr/share/man/man1/wmbusmeters.1.gz
echo man page: removed "$ROOT"/usr/share/man/man1/wmbusmeters.1.gz
fi
if [ -f "$ROOT"/etc/logrotate.d/wmbusmeters ]
then
rm "$ROOT"/etc/logrotate.d/wmbusmeters
echo logrotate file: removed "$ROOT"/etc/logrotate.d/wmbusmeters
fi
if [ -f "$ROOT"/lib/systemd/system/wmbusmeters.service ]
then
rm "$ROOT"/lib/systemd/system/wmbusmeters.service
echo systemd: removed "$ROOT"/lib/systemd/system/wmbusmeters.service
fi