From db31a1050397b98900b4fc126a97ee52874eebd0 Mon Sep 17 00:00:00 2001 From: "Austin S. Hemmelgarn" Date: Mon, 13 Jan 2025 10:04:20 -0500 Subject: [PATCH] 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. --- packaging/installer/kickstart.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh index 6a9204e64435e2..26f6f795100b4c 100755 --- a/packaging/installer/kickstart.sh +++ b/packaging/installer/kickstart.sh @@ -20,12 +20,26 @@ KICKSTART_SOURCE="$( echo "$(pwd -P)/${self##*/}" )" DEFAULT_PLUGIN_PACKAGES="" -PATH="${PATH}:/usr/local/bin:/usr/local/sbin" REPOCONFIG_DEB_VERSION="4-1" REPOCONFIG_RPM_VERSION="4-1" START_TIME="$(date +%s)" STATIC_INSTALL_ARCHES="x86_64 armv7l armv6l aarch64 ppc64le" +# ====================================================================== +# Properly sort out inconsistencies in `$PATH` across distros +# +# Debian and Ubuntu still don’t include sbin directories for regular +# users (even though the distinction is all but pointless at this point in +# time), and a number of distros don’t include the standard paths under +# `/usr/local` either. + +for dir in /usr/sbin /sbin /usr/local/bin /usr/local/sbin ; do + case ":${PATH}:" in + *:${dir}:*) ;; + *) PATH="${PATH}:${dir}" ;; + esac +done + # ====================================================================== # URLs used throughout the script @@ -1279,7 +1293,11 @@ write_claim_config() { run_as_root mv -f "${claim_config}.tmp" "${claim_config}" || return 1 if [ -z "${NETDATA_CLAIM_NORELOAD}" ]; then - run_as_root "${netdatacli}" reload-claiming-state || return 1 + if [ -n "${netdatacli}" ]; then + run_as_root "${netdatacli}" reload-claiming-state || return 1 + else + warning "Unable to find the netdatacli binary, the agent must be restarted to finish claiming" + fi fi }