forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-remove.sh
42 lines (36 loc) · 939 Bytes
/
post-remove.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
#!/bin/bash
function disable_systemd {
systemctl disable telegraf
rm -f /lib/systemd/system/telegraf.service
}
function disable_update_rcd {
update-rc.d -f telegraf remove
rm -f /etc/init.d/telegraf
}
function disable_chkconfig {
chkconfig --del telegraf
rm -f /etc/init.d/telegraf
}
if [[ "$1" == "0" ]]; then
# RHEL and any distribution that follow RHEL, Amazon Linux covered
# telegraf is no longer installed, remove from init system
rm -f /etc/default/telegraf
which systemctl &>/dev/null
if [[ $? -eq 0 ]]; then
disable_systemd
else
# Assuming sysv
disable_chkconfig
fi
elif [ "$1" == "remove" -o "$1" == "purge" ]; then
# Debian/Ubuntu logic
# Remove/purge
rm -f /etc/default/telegraf
which systemctl &>/dev/null
if [[ $? -eq 0 ]]; then
disable_systemd
else
# Assuming sysv
disable_update_rcd
fi
fi