netdata/installer: do not enable netdata, if it was previously disabled (#6606)
* netdata/installer: do not enable netdata, if it was previously disabled * netdata/installer: echo to true * netdata/packaging: attend codacy warning
Paul Emm. Katsoulakis committed
Aug 6, 2019 at 20:51 UTC
b8836f0b632250551e84a5ac6e96f9537678846c
1 file changed
+8
-1
packaging/installer/functions.sh
+8
-1
@@ -380,10 +380,17 @@ install_netdata_service() {
380
fi
381
382
if [ "${SYSTEMD_DIRECTORY}x" != "x" ]; then
383
+ ENABLE_NETDATA_IF_PREVIOUSLY_ENABLED="run systemctl enable netdata"
384
+ IS_NETDATA_ENABLED="$(systemctl is-enabled netdata 2> /dev/null || echo "Netdata not there")"
385
+ if [ "${IS_NETDATA_ENABLED}" == "disabled" ]; then
386
+ echo >&2 "Netdata was there and disabled, make sure we don't re-enable it ourselves"
387
+ ENABLE_NETDATA_IF_PREVIOUSLY_ENABLED="true"
388
+ fi
389
+
390
echo >&2 "Installing systemd service..."
391
run cp system/netdata.service "${SYSTEMD_DIRECTORY}/netdata.service" &&
392
run systemctl daemon-reload &&
386
- run systemctl enable netdata &&
393
+ ${ENABLE_NETDATA_IF_PREVIOUSLY_ENABLED} &&
394
return 0
395
else
396
echo >&2 "no systemd directory; cannot install netdata.service"