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
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
;;
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}"
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
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
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
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