From 1d47a45e93feee6ab2d9e1688da537c978374148 Mon Sep 17 00:00:00 2001 From: Gunnar <628831+gunnaraasen@users.noreply.github.com> Date: Wed, 6 Feb 2019 16:17:11 -0800 Subject: [PATCH] Use Systemd for Amazon Linux 2 packages (#5387) --- scripts/post-install.sh | 5 ++++- scripts/post-remove.sh | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/post-install.sh b/scripts/post-install.sh index 6c73fef8ea307..822a4e4de5028 100644 --- a/scripts/post-install.sh +++ b/scripts/post-install.sh @@ -88,7 +88,10 @@ elif [[ -f /etc/debian_version ]]; then fi elif [[ -f /etc/os-release ]]; then source /etc/os-release - if [[ $ID = "amzn" ]]; then + if [[ "$NAME" = "Amazon Linux" ]]; then + # Amazon Linux 2+ logic + install_systemd /usr/lib/systemd/system/telegraf.service + elif [[ "$NAME" = "Amazon Linux AMI" ]]; then # Amazon Linux logic install_init # Run update-rc.d or fallback to chkconfig if not available diff --git a/scripts/post-remove.sh b/scripts/post-remove.sh index b4b6f18fbe5c6..533a4fec12028 100644 --- a/scripts/post-remove.sh +++ b/scripts/post-remove.sh @@ -48,11 +48,15 @@ elif [[ -f /etc/debian_version ]]; then fi elif [[ -f /etc/os-release ]]; then source /etc/os-release - if [[ $ID = "amzn" ]]; then - # Amazon Linux logic - if [[ "$1" = "0" ]]; then - # InfluxDB is no longer installed, remove from init system - rm -f /etc/default/telegraf + 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 disable_chkconfig fi fi