diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2022-04-11 07:04:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-11 07:04:31 -0400 |
commit | 0fcf54e0c998d249b682f5dace6458cf64dc0842 (patch) | |
tree | 7cb3e72614a1946156a019956a3ca3c4c8625851 /packaging | |
parent | 6b2534969aa7fa9d09d1c72afc00c3aa6513b537 (diff) |
Add handling for claiming non-standard install types with kickstart. (#12064)
* Add handling for claiming non-standard install types with kickstart.
Also adds a check to verify that there is a usable claiming script
before attempting to claim.
* Fix handling for claiming native installs.
* Make claim script search code more robust.
Diffstat (limited to 'packaging')
-rwxr-xr-x | packaging/installer/kickstart.sh | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh index f037e74b4c..10e689cc5a 100755 --- a/packaging/installer/kickstart.sh +++ b/packaging/installer/kickstart.sh @@ -662,7 +662,7 @@ detect_existing_install() { ndprefix="$(dirname "$(dirname "${ndpath}")")" fi - if echo "${ndprefix}" | grep -Eq '/usr$'; then + if echo "${ndprefix}" | grep -Eq '^/usr$'; then ndprefix="$(dirname "${ndprefix}")" fi fi @@ -784,7 +784,20 @@ handle_existing_install() { fi fi else - fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported, refusing to proceed." F0103 + if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then + progress "Attempting to claim existing install at ${ndprefix}." + INSTALL_PREFIX="${ndprefix}" + claim + ret=$? + + cleanup + trap - EXIT + exit $ret + elif [ "${NETDATA_CLAIM_ONLY}" -eq 1 ]; then + fatal "User asked to claim, but did not proide a claiming token." F0202 + else + fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported, refusing to proceed." F0103 + fi fi ;; esac @@ -890,14 +903,26 @@ claim() { fi progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}" - if [ -z "${INSTALL_PREFIX}" ] || [ "${INSTALL_PREFIX}" = "/" ]; then + if command -v netdata-claim.sh > /dev/null 2>&1; then + NETDATA_CLAIM_PATH="$(command -v netdata-claim.sh)" + elif [ -z "${INSTALL_PREFIX}" ] || [ "${INSTALL_PREFIX}" = "/" ]; then NETDATA_CLAIM_PATH=/usr/sbin/netdata-claim.sh elif [ "${INSTALL_PREFIX}" = "/opt/netdata" ]; then NETDATA_CLAIM_PATH="/opt/netdata/bin/netdata-claim.sh" + elif [ ! -d "${INSTALL_PREFIX}/netdata" ]; then + if [ -d "${INSTALL_PREFIX}/usr" ]; then + NETDATA_CLAIM_PATH="${INSTALL_PREFIX}/usr/sbin/netdata-claim.sh" + else + NETDATA_CLAIM_PATH="${INSTALL_PREFIX}/sbin/netdata-claim.sh" + fi else NETDATA_CLAIM_PATH="${INSTALL_PREFIX}/netdata/usr/sbin/netdata-claim.sh" fi + if [ ! -x "${NETDATA_CLAIM_PATH}" ]; then + fatal "Unable to find usable claiming script." F0106 + fi + if ! is_netdata_running; then NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -daemon-not-running" fi |