From a0d75bd5d4f83839a68f38286aa421f4bb828b8a Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Mon, 30 May 2016 10:39:29 +0300 Subject: properly detect systemd --- netdata-installer.sh | 54 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'netdata-installer.sh') diff --git a/netdata-installer.sh b/netdata-installer.sh index 64edab65b8..32b6113019 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -574,36 +574,46 @@ stop_all_netdata() { # ----------------------------------------------------------------------------- # check netdata for systemd +issystemd() { + pidof systemd >/dev/null 2>&1 && return 0 + [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0 + return 1 +} + running=0 -pidof systemd >/dev/null 2>&1 -if [ $? -eq 0 -a "${UID}" -eq 0 ] -then - # systemd is running on this system +if [ "${UID}" -eq 0 ] + then - if [ ! -f /etc/systemd/system/netdata.service ] + if issystemd then - echo >&2 "Installing systemd service..." - run cp system/netdata.service /etc/systemd/system/netdata.service && \ - run systemctl daemon-reload && \ - run systemctl enable netdata - else - run service netdata stop - fi + # systemd is running on this system - stop_all_netdata - run service netdata start && running=1 -fi + if [ ! -f /etc/systemd/system/netdata.service ] + then + echo >&2 "Installing systemd service..." + run cp system/netdata.service /etc/systemd/system/netdata.service && \ + run systemctl daemon-reload && \ + run systemctl enable netdata + else + run service netdata stop + fi -if [ ${running} -eq 0 -a "${UID}" -eq 0 ] -then - service netdata status >/dev/null 2>&1 - if [ $? -eq 0 ] - then - # nice guy, he installed netdata to his system - run service netdata stop stop_all_netdata run service netdata start && running=1 fi + + if [ ${running} -eq 0 ] + then + service netdata status >/dev/null 2>&1 + if [ $? -eq 0 ] + then + # nice guy, he installed netdata to his system + run service netdata stop + stop_all_netdata + run service netdata start && running=1 + fi + fi + fi if [ ${running} -eq 0 ] -- cgit v1.2.3