Add an option to the kickstart script to override distro detection. (#14589)
Takes a single argument consisting of the values of the `ID`, `VERSION_ID`, and `VERSION_CODENAME` fields from the os-release file for the target distribution, separated by `:`. The codename part is optional for non-DEB distros, in which case the final `:` may be left off. This allows for better handling of platforms that are ABI-compatible derivatives of our supported platforms, both in that it allows users to install with native packages on them, and in that it allows us to better test such setups.
Austin S. Hemmelgarn committed
Feb 28, 2023 at 10:30 UTC
76ca052b9d2fb5324946b9d229059892e8e9debd
2 files changed
+75
-47
packaging/installer/kickstart.sh
+74
-47
@@ -2,7 +2,7 @@
2
#
3
# SPDX-License-Identifier: GPL-3.0-or-later
4
#
5
-# Next unused error code: F050F
5
+# Next unused error code: F0512
6
7
# ======================================================================
8
# Constants
@@ -632,71 +632,78 @@ safe_sha256sum() {
632
}
633
634
get_system_info() {
635
+ SYSARCH="$(uname -m)"
636
+
637
case "$(uname -s)" in
638
Linux)
639
SYSTYPE="Linux"
640
639
- os_release_file=
640
- if [ -s "/etc/os-release" ] && [ -r "/etc/os-release" ]; then
641
- os_release_file="/etc/os-release"
642
- elif [ -s "/usr/lib/os-release" ] && [ -r "/usr/lib/os-release" ]; then
643
- os_release_file="/usr/lib/os-release"
644
- else
645
- warning "Cannot find usable OS release information. Native packages will not be available for this install."
646
- fi
647
-
648
- if [ -n "${os_release_file}" ]; then
649
- # shellcheck disable=SC1090
650
- . "${os_release_file}"
651
-
652
- DISTRO="${ID}"
653
- SYSVERSION="${VERSION_ID}"
654
- SYSCODENAME="${VERSION_CODENAME}"
655
- SYSARCH="$(uname -m)"
641
+ if [ -z "${SKIP_DISTRO_DETECTION}" ]; then
642
+ os_release_file=
643
+ if [ -s "/etc/os-release" ] && [ -r "/etc/os-release" ]; then
644
+ os_release_file="/etc/os-release"
645
+ elif [ -s "/usr/lib/os-release" ] && [ -r "/usr/lib/os-release" ]; then
646
+ os_release_file="/usr/lib/os-release"
647
+ else
648
+ warning "Cannot find usable OS release information. Native packages will not be available for this install."
649
+ fi
650
657
- supported_compat_names="debian ubuntu centos fedora opensuse ol arch"
651
+ if [ -n "${os_release_file}" ]; then
652
+ # shellcheck disable=SC1090
653
+ . "${os_release_file}"
654
659
- if str_in_list "${DISTRO}" "${supported_compat_names}"; then
660
- DISTRO_COMPAT_NAME="${DISTRO}"
655
+ DISTRO="${ID}"
656
+ SYSVERSION="${VERSION_ID}"
657
+ SYSCODENAME="${VERSION_CODENAME}"
658
else
662
- case "${DISTRO}" in
663
- opensuse-leap)
664
- DISTRO_COMPAT_NAME="opensuse"
665
- ;;
666
- cloudlinux|almalinux|rocky|rhel)
667
- DISTRO_COMPAT_NAME="centos"
668
- ;;
669
- artix|manjaro|obarun)
670
- DISTRO_COMPAT_NAME="arch"
671
- ;;
672
- *)
673
- DISTRO_COMPAT_NAME="unknown"
674
- ;;
675
- esac
659
+ DISTRO="unknown"
660
+ DISTRO_COMPAT_NAME="unknown"
661
+ SYSVERSION="unknown"
662
+ SYSCODENAME="unknown"
663
fi
664
+ else
665
+ warning "Distribution auto-detection overridden by user. This is not guaranteed to work, and is not officially supported."
666
+ fi
667
678
- case "${DISTRO_COMPAT_NAME}" in
679
- centos|ol)
680
- SYSVERSION=$(echo "$SYSVERSION" | cut -d'.' -f1)
681
- ;;
682
- esac
668
+ supported_compat_names="debian ubuntu centos fedora opensuse ol arch"
669
+
670
+ if str_in_list "${DISTRO}" "${supported_compat_names}"; then
671
+ DISTRO_COMPAT_NAME="${DISTRO}"
672
else
684
- DISTRO="unknown"
685
- DISTRO_COMPAT_NAME="unknown"
686
- SYSVERSION="unknown"
687
- SYSCODENAME="unknown"
688
- SYSARCH="$(uname -m)"
673
+ case "${DISTRO}" in
674
+ opensuse-leap)
675
+ DISTRO_COMPAT_NAME="opensuse"
676
+ ;;
677
+ cloudlinux|almalinux|rocky|rhel)
678
+ DISTRO_COMPAT_NAME="centos"
679
+ ;;
680
+ artix|manjaro|obarun)
681
+ DISTRO_COMPAT_NAME="arch"
682
+ ;;
683
+ *)
684
+ DISTRO_COMPAT_NAME="unknown"
685
+ ;;
686
+ esac
687
fi
688
+
689
+ case "${DISTRO_COMPAT_NAME}" in
690
+ centos|ol)
691
+ SYSVERSION=$(echo "$SYSVERSION" | cut -d'.' -f1)
692
+ ;;
693
+ ubuntu|debian)
694
+ if [ -z "${SYSCODENAME}" ]; then
695
+ fatal "Could not determine ${DISTRO} release code name. This is required information on these systems." F0511
696
+ fi
697
+ ;;
698
+ esac
699
;;
700
Darwin)
701
SYSTYPE="Darwin"
702
SYSVERSION="$(sw_vers -buildVersion)"
694
- SYSARCH="$(uname -m)"
703
;;
704
FreeBSD)
705
SYSTYPE="FreeBSD"
706
SYSVERSION="$(uname -K)"
699
- SYSARCH="$(uname -m)"
707
;;
708
*)
709
fatal "Unsupported system type detected. Netdata cannot be installed on this system using this script." F0200
@@ -1477,6 +1484,10 @@ try_package_install() {
1484
;;
1485
esac
1486
1487
+ if [ -n "${SKIP_DISTRO_DETECTION}" ]; then
1488
+ warning "Attempting to use native packages with a distro override. This is not officially supported, but may work in some cases. If your system requires a distro override to use native packages, please open an feature request at ${AGENT_BUG_REPORT_URL} about it so that we can update the installer to auto-detect this."
1489
+ fi
1490
+
1491
if [ -n "${INSTALL_VERSION}" ]; then
1492
if echo "${INSTALL_VERSION}" | grep -q "nightly"; then
1493
new_release="-edge"
@@ -2191,6 +2202,22 @@ parse_args() {
2202
AUTO_UPDATE=0
2203
shift 1
2204
;;
2205
+ "--distro-override")
2206
+ if [ -n "${2}" ]; then
2207
+ SKIP_DISTRO_DETECTION=1
2208
+ DISTRO="$(echo "${2}" | cut -f 1 -d ':' | tr '[:upper:]' '[:lower:]')"
2209
+ SYSVERSION="$(echo "${2}" | cut -f 2 -d ':')"
2210
+ SYSCODENAME="$(echo "${2}" | cut -f 3 -d ':' | tr '[:upper:]' '[:lower:]')"
2211
+
2212
+ if [ -z "${SYSVERSION}" ]; then
2213
+ fatal "You must specify a release as well as a distribution name." F0510
2214
+ fi
2215
+
2216
+ shift 1
2217
+ else
2218
+ fatal "A distribution name and release must be specified for the --distro-override option." F050F
2219
+ fi
2220
+ ;;
2221
"--uninstall")
2222
ACTION="uninstall"
2223
NETDATA_COMMAND="uninstall"
packaging/installer/methods/kickstart.md
+1
@@ -105,6 +105,7 @@ The `kickstart.sh` script accepts a number of optional parameters to control how
105
- `--claim-proxy`: Specify a proxy to use when connecting to the cloud in the form of `http://[user:pass@]host:ip` for an HTTP(S) proxy.
106
See [connecting through a proxy](https://github.com/netdata/netdata/blob/master/claim/README.md#connect-through-a-proxy) for details.
107
- `--claim-url`: Specify a URL to use when connecting to the cloud. Defaults to `https://api.netdata.cloud`.
108
+- `--override-distro`: Override the distro detection logic and assume the system is using a specific Linux distribution and release. Takes a single argument consisting of the values of the `ID`, `VERSION_ID`, and `VERSION_CODENAME` fields from `/etc/os-release` for the desired distribution.
109
110
111
Additionally, the following environment variables may be used to further customize how the script runs (most users