Skip to content

Commit

Permalink
Init script and service cleanup in case of remove operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Srini Chebrolu committed Jun 24, 2016
1 parent ed7bea6 commit f27da53
Showing 1 changed file with 22 additions and 39 deletions.
61 changes: 22 additions & 39 deletions scripts/post-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,29 @@ function disable_chkconfig {
rm -f /etc/init.d/telegraf
}

if [[ -f /etc/redhat-release ]]; then
# RHEL-variant logic
if [[ "$1" = "0" ]]; then
# InfluxDB 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
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 [[ -f /etc/debian_version ]]; then
elif [ "$1" == "remove" -o "$1" == "purge" ]; then
# Debian/Ubuntu logic
if [[ "$1" != "upgrade" ]]; then
# 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
elif [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID = "amzn" ]]; then
# Amazon Linux logic
which systemctl &>/dev/null
if [[ $? -eq 0 ]]; then
# I don't find systemd supported in Amazon Linux yet, but adding as Amazon support telegraf is ready to handle systemd
disable_systemd
rm -f /etc/default/telegraf
else
# Assuming sysv
disable_chkconfig
fi
# 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

0 comments on commit f27da53

Please sign in to comment.