@cryptotaxi247 / netdata-1 / commits / a0d75bd5d

properly detect systemd

Costa Tsaousis (ktsaou) committed May 30, 2016 at 10:39 UTC a0d75bd5d4f83839a68f38286aa421f4bb828b8a
1 file changed +32 -22
netdata-installer.sh
+32 -22
@@ -574,36 +574,46 @@ stop_all_netdata() {
574 # -----------------------------------------------------------------------------
575 # check netdata for systemd
576
577 +issystemd() {
578 + pidof systemd >/dev/null 2>&1 && return 0
579 + [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0
580 + return 1
581 +}
582 +
583 running=0
578 -pidof systemd >/dev/null 2>&1
579 -if [ $? -eq 0 -a "${UID}" -eq 0 ]
580 -then
581 - # systemd is running on this system
584 +if [ "${UID}" -eq 0 ]
585 + then
586
583 - if [ ! -f /etc/systemd/system/netdata.service ]
587 + if issystemd
588 then
585 - echo >&2 "Installing systemd service..."
586 - run cp system/netdata.service /etc/systemd/system/netdata.service && \
587 - run systemctl daemon-reload && \
588 - run systemctl enable netdata
589 - else
590 - run service netdata stop
591 - fi
589 + # systemd is running on this system
590
593 - stop_all_netdata
594 - run service netdata start && running=1
595 -fi
591 + if [ ! -f /etc/systemd/system/netdata.service ]
592 + then
593 + echo >&2 "Installing systemd service..."
594 + run cp system/netdata.service /etc/systemd/system/netdata.service && \
595 + run systemctl daemon-reload && \
596 + run systemctl enable netdata
597 + else
598 + run service netdata stop
599 + fi
600
597 -if [ ${running} -eq 0 -a "${UID}" -eq 0 ]
598 -then
599 - service netdata status >/dev/null 2>&1
600 - if [ $? -eq 0 ]
601 - then
602 - # nice guy, he installed netdata to his system
603 - run service netdata stop
601 stop_all_netdata
602 run service netdata start && running=1
603 fi
604 +
605 + if [ ${running} -eq 0 ]
606 + then
607 + service netdata status >/dev/null 2>&1
608 + if [ $? -eq 0 ]
609 + then
610 + # nice guy, he installed netdata to his system
611 + run service netdata stop
612 + stop_all_netdata
613 + run service netdata start && running=1
614 + fi
615 + fi
616 +
617 fi
618
619 if [ ${running} -eq 0 ]