Skip to content

Commit

Permalink
fix systemd path in order to add compatibility with SuSe
Browse files Browse the repository at this point in the history
  • Loading branch information
NAHELOU SÉBASTIEN committed Mar 8, 2017
1 parent ceb36ad commit 2afbc30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions scripts/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions scripts/post-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function disable_systemd {
systemctl disable telegraf
rm -f /lib/systemd/system/telegraf.service
rm -f $1
}

function disable_update_rcd {
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2afbc30

Please sign in to comment.