@cryptotaxi247 / netdata-1 / commits / db31a1050

Fix issues with $PATH and netdatacli detection. (#19371)

- Account for Debian/Ubuntu still not including sbin directories in user $PATH. - Report an inability to detect netdatacli location instead of trying to invoke an empty string when claiming.

Austin S. Hemmelgarn committed Jan 13, 2025 at 10:04 UTC db31a1050397b98900b4fc126a97ee52874eebd0
1 file changed +20 -2
packaging/installer/kickstart.sh
+20 -2
@@ -20,12 +20,26 @@ KICKSTART_SOURCE="$(
20 echo "$(pwd -P)/${self##*/}"
21 )"
22 DEFAULT_PLUGIN_PACKAGES=""
23 -PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
23 REPOCONFIG_DEB_VERSION="4-1"
24 REPOCONFIG_RPM_VERSION="4-1"
25 START_TIME="$(date +%s)"
26 STATIC_INSTALL_ARCHES="x86_64 armv7l armv6l aarch64 ppc64le"
27
28 +# ======================================================================
29 +# Properly sort out inconsistencies in `$PATH` across distros
30 +#
31 +# Debian and Ubuntu still don’t include sbin directories for regular
32 +# users (even though the distinction is all but pointless at this point in
33 +# time), and a number of distros don’t include the standard paths under
34 +# `/usr/local` either.
35 +
36 +for dir in /usr/sbin /sbin /usr/local/bin /usr/local/sbin ; do
37 + case ":${PATH}:" in
38 + *:${dir}:*) ;;
39 + *) PATH="${PATH}:${dir}" ;;
40 + esac
41 +done
42 +
43 # ======================================================================
44 # URLs used throughout the script
45
@@ -1279,7 +1293,11 @@ write_claim_config() {
1293 run_as_root mv -f "${claim_config}.tmp" "${claim_config}" || return 1
1294
1295 if [ -z "${NETDATA_CLAIM_NORELOAD}" ]; then
1282 - run_as_root "${netdatacli}" reload-claiming-state || return 1
1296 + if [ -n "${netdatacli}" ]; then
1297 + run_as_root "${netdatacli}" reload-claiming-state || return 1
1298 + else
1299 + warning "Unable to find the netdatacli binary, the agent must be restarted to finish claiming"
1300 + fi
1301 fi
1302 }
1303