@cryptotaxi247 / netdata-1 / commits / 2232a2511

Provide improved messaging in the kickstart script for existing installs managed by the system package manager. (#13947)

* Add support for a handful of popular Arch derivatives. This just ensures we detect them correctly as Arch clones. No functional change in behavior, this just ensures they will work correctly when we start checking for pre-existing package installs on non DEB/RPM platforms. * Expand installed package detection support. This adds support for checking for installed packages on Linux systems using APK (Alpine) or Pacman (Arch and it’s derivatives), as well as macOS systems using Homebrew, and FreeBSD systems where the `pkg` command has been set up. * Differentiate messaging for existing installs managed by the system PM. This allows us to provide more concrete explanations of what the user needs to do in such cases. * Fix missing entry in supported_compat_names for Arch Linux.

Austin S. Hemmelgarn committed Nov 8, 2022 at 07:23 UTC 2232a2511dc4746ae4b14543ad2a367718f57300
1 file changed +67 -15
packaging/installer/kickstart.sh
+67 -15
@@ -632,7 +632,7 @@ get_system_info() {
632 SYSCODENAME="${VERSION_CODENAME}"
633 SYSARCH="$(uname -m)"
634
635 - supported_compat_names="debian ubuntu centos fedora opensuse ol"
635 + supported_compat_names="debian ubuntu centos fedora opensuse ol arch"
636
637 if str_in_list "${DISTRO}" "${supported_compat_names}"; then
638 DISTRO_COMPAT_NAME="${DISTRO}"
@@ -644,6 +644,9 @@ get_system_info() {
644 cloudlinux|almalinux|rocky|rhel)
645 DISTRO_COMPAT_NAME="centos"
646 ;;
647 + artix|manjaro|obarun)
648 + DISTRO_COMPAT_NAME="arch"
649 + ;;
650 *)
651 DISTRO_COMPAT_NAME="unknown"
652 ;;
@@ -814,7 +817,9 @@ detect_existing_install() {
817
818 if pkg_installed netdata; then
819 ndprefix="/"
820 + EXISTING_INSTALL_IS_NATIVE="1"
821 else
822 + EXISTING_INSTALL_IS_NATIVE="0"
823 if [ -n "${INSTALL_PREFIX}" ]; then
824 searchpath="${INSTALL_PREFIX}/bin:${INSTALL_PREFIX}/sbin:${INSTALL_PREFIX}/usr/bin:${INSTALL_PREFIX}/usr/sbin:${PATH}"
825 searchpath="${INSTALL_PREFIX}/netdata/bin:${INSTALL_PREFIX}/netdata/sbin:${INSTALL_PREFIX}/netdata/usr/bin:${INSTALL_PREFIX}/netdata/usr/sbin:${searchpath}"
@@ -879,7 +884,11 @@ handle_existing_install() {
884 case "${INSTALL_TYPE}" in
885 kickstart-*|legacy-*|binpkg-*|manual-static|unknown)
886 if [ "${INSTALL_TYPE}" = "unknown" ]; then
882 - warning "Found an existing netdata install at ${ndprefix}, but could not determine the install type. Usually this means you installed Netdata through your distribution’s regular package repositories or some other unsupported method."
887 + if [ "${EXISTING_INSTALL_IS_NATIVE}" -eq 1 ]; then
888 + warning "Found an existing netdata install managed by the system package manager, but could not determine the install type. Usually this means you installed an unsupported third-party netdata package."
889 + else
890 + warning "Found an existing netdata install at ${ndprefix}, but could not determine the install type. Usually this means you installed Netdata through your distribution’s regular package repositories or some other unsupported method."
891 + fi
892 else
893 progress "Found an existing netdata install at ${ndprefix}, with installation type '${INSTALL_TYPE}'."
894 fi
@@ -897,7 +906,13 @@ handle_existing_install() {
906 elif [ "${INTERACTIVE}" -eq 0 ]; then
907 fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting." F0104
908 else
900 - if confirm "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, do you want to continue?"; then
909 + if [ "${EXISTING_INSTALL_IS_NATIVE}" ]; then
910 + reinstall_prompt="Reinstalling over top of an existing install managed by the system package manager is known to cause things to break, are you sure you want to continue?"
911 + else
912 + reinstall_prompt="Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, do you want to continue?"
913 + fi
914 +
915 + if confirm "${reinstall_prompt}"; then
916 progress "OK, continuing."
917 else
918 fatal "Cancelling reinstallation at user request." F0105
@@ -908,10 +923,18 @@ handle_existing_install() {
923
924 return 0
925 elif [ "${INSTALL_TYPE}" = "unknown" ]; then
926 + claimonly_notice="If you just want to claim this install, you should re-run this command with the --claim-only option instead."
927 + if [ "${EXISTING_INSTALL_IS_NATIVE}" -eq 1 ]; then
928 + failmsg="Attempting to update an installation managed by the system package manager is known to not work in most cases. If you are trying to install the latest version of Netdata, you will need to manually uninstall it through your system package manager. ${claimonly_notice}"
929 + promptmsg="Attempting to update an installation managed by the system package manager is known to not work in most cases. If you are trying to install the latest version of Netdata, you will need to manually uninstall it through your system package manager. ${claimonly_notice} Are you sure you want to continue?"
930 + else
931 + failmsg="We do not support trying to update or claim installations when we cannot determine the install type. You will need to uninstall the existing install using the same method you used to install it to proceed. ${claimonly_notice}"
932 + promptmsg="Attempting to update an existing install is not officially supported. It may work, but it also might break your system. ${claimonly_notice} Are you sure you want to continue?"
933 + fi
934 if [ "${INTERACTIVE}" -eq 0 ] && [ "${NETDATA_CLAIM_ONLY}" -eq 0 ]; then
912 - fatal "We do not support trying to update or claim installations when we cannot determine the install type. You will need to uninstall the existing install using the same method you used to install it to proceed. If you just want to claim this install, you can re-run this command with the --claim-only option." F0106
935 + fatal "${failmsg}" F0106
936 elif [ "${INTERACTIVE}" -eq 1 ] && [ "${NETDATA_CLAIM_ONLY}" -eq 0 ]; then
914 - if confirm "Attempting to update an existing install is not officially supported. It may work, but it also might break your system. If you just want to claim this install, you should re-run this command with the --claim-only option instead. Are you sure you want to continue?"; then
937 + if confirm "${promptmsg}"; then
938 progress "OK, continuing"
939 else
940 fatal "Cancelling update of unknown installation type at user request." F050C
@@ -1210,19 +1233,48 @@ set_auto_updates() {
1233
1234 # Check for an already installed package with a given name.
1235 pkg_installed() {
1213 - case "${DISTRO_COMPAT_NAME}" in
1214 - debian|ubuntu)
1215 - # shellcheck disable=SC2016
1216 - dpkg-query --show --showformat '${Status}' "${1}" 2>&1 | cut -f 1 -d ' ' | grep -q '^install$'
1217 - return $?
1236 + case "${SYSTYPE}" in
1237 + Linux)
1238 + case "${DISTRO_COMPAT_NAME}" in
1239 + debian|ubuntu)
1240 + # shellcheck disable=SC2016
1241 + dpkg-query --show --showformat '${Status}' "${1}" 2>&1 | cut -f 1 -d ' ' | grep -q '^install$'
1242 + return $?
1243 + ;;
1244 + centos|fedora|opensuse|ol)
1245 + rpm -q "${1}" > /dev/null 2>&1
1246 + return $?
1247 + ;;
1248 + alpine)
1249 + apk -e info "${1}" > /dev/null 2>&1
1250 + return $?
1251 + ;;
1252 + arch)
1253 + pacman -Qi "${1}" > /dev/null 2>&1
1254 + return $?
1255 + ;;
1256 + *)
1257 + return 1
1258 + ;;
1259 + esac
1260 ;;
1219 - centos|fedora|opensuse|ol)
1220 - rpm -q "${1}" > /dev/null 2>&1
1221 - return $?
1261 + Darwin)
1262 + if command -v brew > /dev/null 2>&1; then
1263 + brew list "${1}" > /dev/null 2>&1
1264 + return $?
1265 + else
1266 + return 1
1267 + fi
1268 ;;
1223 - *)
1224 - return 1
1269 + FreeBSD)
1270 + if pkg -N > /dev/null 2>&1; then
1271 + pkg info "${1}" > /dev/null 2>&1
1272 + return $?
1273 + else
1274 + return 1
1275 + fi
1276 ;;
1277 + *) return 1 ;;
1278 esac
1279 }
1280