diff options
-rwxr-xr-x | netdata-installer.sh | 54 |
1 files changed, 32 insertions, 22 deletions
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 ] |