@cryptotaxi247 / netdata-1 / commits / 44f652473

Fix detection of existing installs. (#12199)

To avoid bogus false positives on macOS, FreeBSD, and cases on Linux systems where the user is specifying an install prefix.

Austin S. Hemmelgarn committed Mar 2, 2022 at 10:14 UTC 44f652473af4e515cfe10a498336e372bf6acda9
1 file changed +13 -15
packaging/installer/kickstart.sh
+13 -15
@@ -537,6 +537,8 @@ uninstall() {
537 get_system_info
538 detect_existing_install
539
540 + export INSTALL_PREFIX="${ndprefix}"
541 +
542 if [ $INTERACTIVE = 0 ]; then
543 FLAGS="--yes --force"
544 else
@@ -557,8 +559,6 @@ uninstall() {
559 detect_existing_install() {
560 if pkg_installed netdata; then
561 ndprefix="/"
560 - elif [ -n "${INSTALL_PREFIX}" ]; then
561 - ndprefix="${INSTALL_PREFIX}"
562 else
563 if [ -n "${INSTALL_PREFIX}" ]; then
564 searchpath="${INSTALL_PREFIX}/bin:${INSTALL_PREFIX}/sbin:${INSTALL_PREFIX}/usr/bin:${INSTALL_PREFIX}/usr/sbin:${PATH}"
@@ -592,16 +592,12 @@ detect_existing_install() {
592 INSTALL_TYPE="unknown"
593 fi
594 fi
595 -
596 - INSTALL_PREFIX="${ndprefix}"
597 -
598 - export INSTALL_PREFIX="${INSTALL_PREFIX}"
595 }
596
597 handle_existing_install() {
598 detect_existing_install
599
604 - if [ -z "${INSTALL_PREFIX}" ] || [ -z "${INSTALL_TYPE}" ]; then
600 + if [ -z "${ndprefix}" ] || [ -z "${INSTALL_TYPE}" ]; then
601 progress "No existing installations of netdata found, assuming this is a fresh install."
602 return 0
603 fi
@@ -609,14 +605,15 @@ handle_existing_install() {
605 case "${INSTALL_TYPE}" in
606 kickstart-*|legacy-*|binpkg-*|manual-static|unknown)
607 if [ "${INSTALL_TYPE}" = "unknown" ]; then
612 - warning "Found an existing netdata install at ${INSTALL_PREFIX}, but could not determine the install type."
608 +
609 + warning "Found an existing netdata install at ${ndprefix}, but could not determine the install type."
610 warning "Usually this means you installed Netdata through your distribution’s regular package repositories or some other unsupported method."
611 else
615 - progress "Found an existing netdata install at ${INSTALL_PREFIX}, with installation type '${INSTALL_TYPE}'."
612 + progress "Found an existing netdata install at ${ndprefix}, with installation type '${INSTALL_TYPE}'."
613 fi
614
615 if [ -n "${NETDATA_REINSTALL}" ] || [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then
619 - progress "Found an existing netdata install at ${INSTALL_PREFIX}, but user requested reinstall, continuing."
616 + progress "Found an existing netdata install at ${ndprefix}, but user requested reinstall, continuing."
617
618 case "${INSTALL_TYPE}" in
619 binpkg-*) NETDATA_ONLY_NATIVE=1 ;;
@@ -646,20 +643,21 @@ handle_existing_install() {
643
644 if [ "${NETDATA_CLAIM_ONLY}" -eq 0 ] && echo "${INSTALL_TYPE}" | grep -vq "binpkg-*"; then
645 if ! update; then
649 - warning "Unable to find usable updater script, not updating existing install at ${INSTALL_PREFIX}."
646 + warning "Unable to find usable updater script, not updating existing install at ${ndprefix}."
647 fi
648 else
652 - warning "Not updating existing install at ${INSTALL_PREFIX}."
649 + warning "Not updating existing install at ${ndprefix}."
650 fi
651
652 if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then
656 - progress "Attempting to claim existing install at ${INSTALL_PREFIX}."
653 + progress "Attempting to claim existing install at ${ndprefix}."
654 + INSTALL_PREFIX="${ndprefix}"
655 claim
656 ret=$?
657 elif [ "${NETDATA_CLAIM_ONLY}" -eq 1 ]; then
658 fatal "User asked to claim, but did not proide a claiming token." F0202
659 else
662 - progress "Not attempting to claim existing install at ${INSTALL_PREFIX} (no claiming token provided)."
660 + progress "Not attempting to claim existing install at ${ndprefix} (no claiming token provided)."
661 fi
662
663 cleanup
@@ -683,7 +681,7 @@ handle_existing_install() {
681 fi
682 fi
683 else
686 - fatal "Found an existing netdata install at ${INSTALL_PREFIX}, but the install type is '${INSTALL_TYPE}', which is not supported, refusing to proceed." F0103
684 + fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported, refusing to proceed." F0103
685 fi
686 ;;
687 esac