2016-02-23 17:25:07 +00:00
|
|
|
#!/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
|
|
|
|
}
|
|
|
|
|
2016-07-28 07:34:57 +00:00
|
|
|
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
|
2016-02-23 17:25:07 +00:00
|
|
|
fi
|
2016-07-28 07:34:57 +00:00
|
|
|
elif [ "$1" == "remove" -o "$1" == "purge" ]; then
|
2016-02-23 17:25:07 +00:00
|
|
|
# Debian/Ubuntu logic
|
2016-07-28 07:34:57 +00:00
|
|
|
# Remove/purge
|
|
|
|
rm -f /etc/default/telegraf
|
|
|
|
|
|
|
|
which systemctl &>/dev/null
|
|
|
|
if [[ $? -eq 0 ]]; then
|
|
|
|
disable_systemd
|
|
|
|
else
|
|
|
|
# Assuming sysv
|
|
|
|
disable_update_rcd
|
2016-02-23 17:25:07 +00:00
|
|
|
fi
|
|
|
|
fi
|