From 2afbc30bf3649e9309ee9d592c493d8070037b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?NAHELOU=20S=C3=89BASTIEN?= Date: Tue, 7 Mar 2017 13:43:56 +0100 Subject: [PATCH] fix systemd path in order to add compatibility with SuSe --- scripts/post-install.sh | 8 ++++---- scripts/post-remove.sh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/post-install.sh b/scripts/post-install.sh index 45a19d26c4bac..3526eef6db168 100644 --- a/scripts/post-install.sh +++ b/scripts/post-install.sh @@ -11,7 +11,7 @@ function install_init { } function install_systemd { - cp -f $SCRIPT_DIR/telegraf.service /lib/systemd/system/telegraf.service + cp -f $SCRIPT_DIR/telegraf.service $1 systemctl enable telegraf || true systemctl daemon-reload || true } @@ -58,11 +58,11 @@ if [[ ! -d /etc/telegraf/telegraf.d ]]; then fi # Distribution-specific logic -if [[ -f /etc/redhat-release ]]; then +if [[ -f /etc/redhat-release ]] || [[ -f /etc/SuSE-release ]]; then # RHEL-variant logic which systemctl &>/dev/null if [[ $? -eq 0 ]]; then - install_systemd + install_systemd /usr/lib/systemd/system/telegraf.service else # Assuming sysv install_init @@ -72,7 +72,7 @@ elif [[ -f /etc/debian_version ]]; then # Debian/Ubuntu logic which systemctl &>/dev/null if [[ $? -eq 0 ]]; then - install_systemd + install_systemd /lib/systemd/system/telegraf.service systemctl restart telegraf || echo "WARNING: systemd not running." else # Assuming sysv diff --git a/scripts/post-remove.sh b/scripts/post-remove.sh index 0f262d2252313..1ae049dac3c5e 100644 --- a/scripts/post-remove.sh +++ b/scripts/post-remove.sh @@ -2,7 +2,7 @@ function disable_systemd { systemctl disable telegraf - rm -f /lib/systemd/system/telegraf.service + rm -f $1 } function disable_update_rcd { @@ -22,7 +22,7 @@ if [[ "$1" == "0" ]]; then which systemctl &>/dev/null if [[ $? -eq 0 ]]; then - disable_systemd + disable_systemd /usr/lib/systemd/system/telegraf.service else # Assuming sysv disable_chkconfig @@ -34,7 +34,7 @@ elif [ "$1" == "remove" -o "$1" == "purge" ]; then which systemctl &>/dev/null if [[ $? -eq 0 ]]; then - disable_systemd + disable_systemd /lib/systemd/system/telegraf.service else # Assuming sysv disable_update_rcd