]> arthur.barton.de Git - netdata.git/commitdiff
properly detect systemd
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 30 May 2016 07:39:29 +0000 (10:39 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 30 May 2016 07:39:29 +0000 (10:39 +0300)
netdata-installer.sh

index 64edab65b8bad80fe02dcda01003fc576e76fee3..32b6113019d2ae1f4e3e4962dc293af04a35bc0e 100755 (executable)
@@ -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 ]