Fix missing NETDATA_STOP_CMD in netdata-installer.sh (#8897)
* Fix missing NETDATA_STOP_CMD in netdata-installer.sh * Fix shellcheck warnings * Fix more shellcheck warnings
James Mills committed
May 7, 2020 at 03:34 UTC
935eb39007f7ea3726df46907c5e1d953958e395
2 files changed
+41
-20
netdata-installer.sh
+20
-18
@@ -53,7 +53,7 @@ defer_error_highlighted() {
53
}
54
55
print_deferred_errors() {
56
- if [ -n "${NETDATA_DEFERRED_ERRORS}" ] ; then
56
+ if [ -n "${NETDATA_DEFERRED_ERRORS}" ]; then
57
echo >&2
58
echo >&2 "The following non-fatal errors were encountered during the installation process:"
59
# shellcheck disable=SC2059
@@ -281,7 +281,7 @@ while [ -n "${1}" ]; do
281
"--disable-go") NETDATA_DISABLE_GO=1 ;;
282
"--enable-ebpf") NETDATA_ENABLE_EBPF=1 ;;
283
"--disable-cloud")
284
- if [ -n "${NETDATA_REQUIRE_CLOUD}" ] ; then
284
+ if [ -n "${NETDATA_REQUIRE_CLOUD}" ]; then
285
echo "Cloud explicitly enabled, ignoring --disable-cloud."
286
else
287
NETDATA_DISABLE_CLOUD=1
@@ -289,7 +289,7 @@ while [ -n "${1}" ]; do
289
fi
290
;;
291
"--require-cloud")
292
- if [ -n "${NETDATA_DISABLE_CLOUD}" ] ; then
292
+ if [ -n "${NETDATA_DISABLE_CLOUD}" ]; then
293
echo "Cloud explicitly disabled, ignoring --require-cloud."
294
else
295
NETDATA_REQUIRE_CLOUD=1
@@ -529,7 +529,7 @@ bundle_libmosquitto() {
529
run_ok "libmosquitto built and prepared."
530
else
531
run_failed "Failed to build libmosquitto."
532
- if [ -n "${NETDATA_REQUIRE_CLOUD}" ] ; then
532
+ if [ -n "${NETDATA_REQUIRE_CLOUD}" ]; then
533
exit 1
534
else
535
defer_error_highlighted "Unable to fetch sources for libmosquitto. You will not be able to connect this node to Netdata Cloud."
@@ -537,7 +537,7 @@ bundle_libmosquitto() {
537
fi
538
else
539
run_failed "Unable to fetch sources for libmosquitto."
540
- if [ -n "${NETDATA_REQUIRE_CLOUD}" ] ; then
540
+ if [ -n "${NETDATA_REQUIRE_CLOUD}" ]; then
541
exit 1
542
else
543
defer_error_highlighted "Unable to fetch sources for libmosquitto. You will not be able to connect this node to Netdata Cloud."
@@ -578,7 +578,7 @@ bundle_libwebsockets() {
578
return 0
579
fi
580
581
- if [ -z "$(command -v cmake)" ] ; then
581
+ if [ -z "$(command -v cmake)" ]; then
582
run_failed "Could not find cmake, which is required to build libwebsockets. The install process will continue, but you may not be able to connect this node to Netdata Cloud."
583
defer_error_highlighted "Could not find cmake, which is required to build libwebsockets. The install process will continue, but you may not be able to connect this node to Netdata Cloud."
584
return 0
@@ -603,7 +603,7 @@ bundle_libwebsockets() {
603
run_ok "libwebsockets built and prepared."
604
else
605
run_failed "Failed to build libwebsockets."
606
- if [ -n "${NETDATA_REQUIRE_CLOUD}" ] ; then
606
+ if [ -n "${NETDATA_REQUIRE_CLOUD}" ]; then
607
exit 1
608
else
609
defer_error_highlighted "Failed to build libwebsockets. You may not be able to connect this node to Netdata Cloud."
@@ -611,7 +611,7 @@ bundle_libwebsockets() {
611
fi
612
else
613
run_failed "Unable to fetch sources for libwebsockets."
614
- if [ -n "${NETDATA_REQUIRE_CLOUD}" ] ; then
614
+ if [ -n "${NETDATA_REQUIRE_CLOUD}" ]; then
615
exit 1
616
else
617
defer_error_highlighted "Unable to fetch sources for libwebsockets. You may not be able to connect this node to Netdata Cloud."
@@ -624,7 +624,7 @@ bundle_libwebsockets
624
# -----------------------------------------------------------------------------
625
# If we have the dashboard switching logic, make sure we're on the classic
626
# dashboard during the install (updates don't work correctly otherwise).
627
-if [ -x "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" ] ; then
627
+if [ -x "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" ]; then
628
"${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" classic
629
fi
630
@@ -1035,15 +1035,13 @@ install_react_dashboard() {
1035
DASHBOARD_PACKAGE_BASENAME="dashboard.tar.gz"
1036
1037
if fetch_and_verify "dashboard" \
1038
- "https://github.com/netdata/dashboard/releases/download/${DASHBOARD_PACKAGE_VERSION}/${DASHBOARD_PACKAGE_BASENAME}" \
1039
- "${DASHBOARD_PACKAGE_BASENAME}" \
1040
- "${tmp}" \
1041
- "${NETDATA_LOCAL_TARBALL_OVERRIDE_DASHBOARD}"
1042
- then
1043
- if run tar -xf "${tmp}/${DASHBOARD_PACKAGE_BASENAME}" -C "${tmp}" && \
1044
- copy_react_dashboard "${tmp}/build" && \
1045
- rm -rf "${tmp}"
1046
- then
1038
+ "https://github.com/netdata/dashboard/releases/download/${DASHBOARD_PACKAGE_VERSION}/${DASHBOARD_PACKAGE_BASENAME}" \
1039
+ "${DASHBOARD_PACKAGE_BASENAME}" \
1040
+ "${tmp}" \
1041
+ "${NETDATA_LOCAL_TARBALL_OVERRIDE_DASHBOARD}"; then
1042
+ if run tar -xf "${tmp}/${DASHBOARD_PACKAGE_BASENAME}" -C "${tmp}" &&
1043
+ copy_react_dashboard "${tmp}/build" &&
1044
+ rm -rf "${tmp}"; then
1045
run_ok "React dashboard installed."
1046
else
1047
run_failed "Failed to install React dashboard. The install process will continue, but you will not be able to use the new dashboard."
@@ -1405,6 +1403,10 @@ fi
1403
# -----------------------------------------------------------------------------
1404
progress "Install netdata at system init"
1405
1406
+# By default we assume the shutdown/startup of the Netdata Agent are effectively
1407
+# without any system supervisor/init like SystemD or SysV. So we assume the most
1408
+# basic startup/shutdown commands...
1409
+NETDATA_STOP_CMD="${NETDATA_PREFIX}/usr/bin/netdatacli shutdown-agent"
1410
NETDATA_START_CMD="${NETDATA_PREFIX}/usr/sbin/netdata"
1411
1412
if grep -q docker /proc/1/cgroup > /dev/null 2>&1; then
packaging/installer/functions.sh
+21
-2
@@ -400,6 +400,10 @@ install_non_systemd_init() {
400
return 1
401
}
402
403
+# This is used by netdata-installer.sh
404
+# shellcheck disable=SC2034
405
+NETDATA_STOP_CMD="netdatacli shutdown-agent"
406
+
407
NETDATA_START_CMD="netdata"
408
NETDATA_INSTALLER_START_CMD=""
409
@@ -425,14 +429,20 @@ install_netdata_service() {
429
return 0
430
else
431
echo >&2 "Installing MacOS X plist file..."
432
+ # This is used by netdata-installer.sh
433
+ # shellcheck disable=SC2034
434
run cp system/netdata.plist /Library/LaunchDaemons/com.github.netdata.plist &&
435
run launchctl load /Library/LaunchDaemons/com.github.netdata.plist &&
430
- return 0
436
+ NETDATA_START_CMD="launchctl start com.github.netdata" &&
437
+ NETDATA_STOP_CMD="launchctl stop com.github.netdata"
438
+ return 0
439
fi
440
441
elif [ "${uname}" = "FreeBSD" ]; then
434
-
442
+ # This is used by netdata-installer.sh
443
+ # shellcheck disable=SC2034
444
run cp system/netdata-freebsd /etc/rc.d/netdata && NETDATA_START_CMD="service netdata start" &&
445
+ NETDATA_STOP_CMD="service netdata stop" &&
446
NETDATA_INSTALLER_START_CMD="service netdata onestart" &&
447
myret=$?
448
@@ -444,6 +454,9 @@ install_netdata_service() {
454
elif issystemd; then
455
# systemd is running on this system
456
NETDATA_START_CMD="systemctl start netdata"
457
+ # This is used by netdata-installer.sh
458
+ # shellcheck disable=SC2034
459
+ NETDATA_STOP_CMD="systemctl stop netdata"
460
NETDATA_INSTALLER_START_CMD="${NETDATA_START_CMD}"
461
462
SYSTEMD_DIRECTORY=""
@@ -483,8 +496,14 @@ install_netdata_service() {
496
if [ ${ret} -eq 0 ]; then
497
if [ -n "${service_cmd}" ]; then
498
NETDATA_START_CMD="service netdata start"
499
+ # This is used by netdata-installer.sh
500
+ # shellcheck disable=SC2034
501
+ NETDATA_STOP_CMD="service netdata stop"
502
elif [ -n "${rcservice_cmd}" ]; then
503
NETDATA_START_CMD="rc-service netdata start"
504
+ # This is used by netdata-installer.sh
505
+ # shellcheck disable=SC2034
506
+ NETDATA_STOP_CMD="rc-service netdata stop"
507
fi
508
NETDATA_INSTALLER_START_CMD="${NETDATA_START_CMD}"
509
fi