@cryptotaxi247 / netdata-1 / commits / d523d3d7d

Update functions.sh (#4643)

Add systemd detection support for SLES 12.3

tsingletonacic committed Nov 13, 2018 at 17:25 UTC d523d3d7d6906e597414b05e3a658b3a4d3c195f
1 file changed +14 -4
installer/functions.sh
+14 -4
@@ -441,8 +441,8 @@ iscontainer() {
441 issystemd() {
442 local pids p myns ns systemctl
443
444 - # if the directory /lib/systemd/system does not exit, it is not systemd
445 - [ ! -d /lib/systemd/system ] && return 1
444 + # if the directory /lib/systemd/system OR /usr/lib/systemd/system (SLES 12.x) does not exit, it is not systemd
445 + [ ! -d /lib/systemd/system -a ! -d /usr/lib/systemd/system ] && return 1
446
447 # if there is no systemctl command, it is not systemd
448 # shellcheck disable=SC2230
@@ -563,15 +563,25 @@ install_netdata_service() {
563 NETDATA_START_CMD="systemctl start netdata"
564 NETDATA_STOP_CMD="systemctl stop netdata"
565
566 + SYSTEMD_DIRECTORY=""
567 +
568 if [ -d "/lib/systemd/system" ]
569 + then
570 + SYSTEMD_DIRECTORY="/lib/systemd/system"
571 + elif [ -d "/usr/lib/systemd/system" ]
572 + then
573 + SYSTEMD_DIRECTORY="/usr/lib/systemd/system"
574 + fi
575 +
576 + if [ "${SYSTEMD_DIRECTORY}x" != "x" ]
577 then
578 echo >&2 "Installing systemd service..."
569 - run cp system/netdata.service /lib/systemd/system/netdata.service && \
579 + run cp system/netdata.service "${SYSTEMD_DIRECTORY}/netdata.service" && \
580 run systemctl daemon-reload && \
581 run systemctl enable netdata && \
582 return 0
583 else
574 - echo >&2 "no '/lib/systemd/system' directory; cannot install netdata.service"
584 + echo >&2 "no systemd directory; cannot install netdata.service"
585 fi
586 else
587 install_non_systemd_init