2016-02-23 17:25:07 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
function disable_systemd {
|
|
|
|
systemctl disable telegraf
|
2017-05-05 21:04:33 +00:00
|
|
|
rm -f $1
|
2016-02-23 17:25:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:04:33 +00:00
|
|
|
if [[ -f /etc/redhat-release ]] || [[ -f /etc/SuSE-release ]]; then
|
2017-04-20 18:19:33 +00:00
|
|
|
# RHEL-variant logic
|
|
|
|
if [[ "$1" = "0" ]]; then
|
|
|
|
# InfluxDB is no longer installed, remove from init system
|
|
|
|
rm -f /etc/default/telegraf
|
2016-07-28 07:34:57 +00:00
|
|
|
|
2017-04-20 18:19:33 +00:00
|
|
|
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
|
2017-05-05 21:04:33 +00:00
|
|
|
disable_systemd /usr/lib/systemd/system/telegraf.service
|
2017-04-20 18:19:33 +00:00
|
|
|
else
|
|
|
|
# Assuming sysv
|
|
|
|
disable_chkconfig
|
|
|
|
fi
|
2016-02-23 17:25:07 +00:00
|
|
|
fi
|
2017-04-20 18:19:33 +00:00
|
|
|
elif [[ -f /etc/debian_version ]]; then
|
2016-02-23 17:25:07 +00:00
|
|
|
# Debian/Ubuntu logic
|
2017-04-20 18:19:33 +00:00
|
|
|
if [ "$1" == "remove" -o "$1" == "purge" ]; then
|
|
|
|
# Remove/purge
|
|
|
|
rm -f /etc/default/telegraf
|
2016-07-28 07:34:57 +00:00
|
|
|
|
2017-04-20 18:19:33 +00:00
|
|
|
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
|
2017-05-05 21:04:33 +00:00
|
|
|
disable_systemd /lib/systemd/system/telegraf.service
|
2017-04-20 18:19:33 +00:00
|
|
|
else
|
|
|
|
# Assuming sysv
|
|
|
|
# Run update-rc.d or fallback to chkconfig if not available
|
|
|
|
if which update-rc.d &>/dev/null; then
|
|
|
|
disable_update_rcd
|
|
|
|
else
|
|
|
|
disable_chkconfig
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
elif [[ -f /etc/os-release ]]; then
|
|
|
|
source /etc/os-release
|
2019-02-07 00:17:11 +00:00
|
|
|
if [[ "$ID" = "amzn" ]] && [[ "$1" = "0" ]]; then
|
|
|
|
# InfluxDB is no longer installed, remove from init system
|
|
|
|
rm -f /etc/default/telegraf
|
|
|
|
|
|
|
|
if [[ "$NAME" = "Amazon Linux" ]]; then
|
|
|
|
# Amazon Linux 2+ logic
|
|
|
|
disable_systemd /usr/lib/systemd/system/telegraf.service
|
|
|
|
elif [[ "$NAME" = "Amazon Linux AMI" ]]; then
|
|
|
|
# Amazon Linux logic
|
2017-04-20 18:19:33 +00:00
|
|
|
disable_chkconfig
|
|
|
|
fi
|
2020-06-03 06:20:45 +00:00
|
|
|
elif [[ "$NAME" = "Solus" ]]; then
|
|
|
|
rm -f /etc/default/telegraf
|
|
|
|
disable_systemd /usr/lib/systemd/system/telegraf.service
|
2016-02-23 17:25:07 +00:00
|
|
|
fi
|
|
|
|
fi
|