summaryrefslogtreecommitdiffstats
path: root/netdata-installer.sh
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-05-30 10:39:29 +0300
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-05-30 10:39:29 +0300
commita0d75bd5d4f83839a68f38286aa421f4bb828b8a (patch)
treeb41dc954230ca6069440b0e4419a6776833a6577 /netdata-installer.sh
parent87c1327cf66b740a1ef537862a326d265898cb5e (diff)
properly detect systemd
Diffstat (limited to 'netdata-installer.sh')
-rwxr-xr-xnetdata-installer.sh54
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 ]