From 25e5018ae34f7bc1ce4ea1b43aeb424e82f3901e Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Mon, 30 May 2016 12:21:34 +0300 Subject: [PATCH] additional checks for the existance of systemd; always attempt to use the service command for managing netdata --- netdata-installer.sh | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/netdata-installer.sh b/netdata-installer.sh index 32b61130..f8abd5b0 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -575,12 +575,20 @@ stop_all_netdata() { # check netdata for systemd issystemd() { - pidof systemd >/dev/null 2>&1 && return 0 + # if the directory /etc/systemd/system does not exit, it is not systemd + [ ! -d /etc/systemd/system ] && return 1 + + # if pid 1 is systemd, it is systemd [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0 + + # if systemd is running, it is systemd + pidof systemd >/dev/null 2>&1 && return 0 + + # else, it is not systemd return 1 } -running=0 +started=0 if [ "${UID}" -eq 0 ] then @@ -599,26 +607,21 @@ if [ "${UID}" -eq 0 ] fi stop_all_netdata - run service netdata start && running=1 + run service netdata start && started=1 fi - if [ ${running} -eq 0 ] + if [ ${started} -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 + # check if we can use the system service + run service netdata stop + stop_all_netdata + run service netdata start && started=1 fi - fi -if [ ${running} -eq 0 ] +if [ ${started} -eq 0 ] then - # still not running... + # still not started... stop_all_netdata -- 2.39.2