summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2020-01-16 07:27:47 -0500
committerGitHub <noreply@github.com>2020-01-16 07:27:47 -0500
commit81251da72c50c0b9efe9efced75452069c4834cb (patch)
tree80fccfe06cbb1a17bd24eb7321e84fb818177954
parentd6c35a1a43ae04dfd0817512b5aacad3287bb8d1 (diff)
Move the script for installing required packages into the main repo. (#7563)
* Move the script for installing required packages into the main repo. Based on discussion with Costa. Most of what this script is actually used for directly is in the main repo anyway, so it makes more sense to have it there so that any changes get reviewed properly. * Fix typo in RPM package build setup.
-rw-r--r--.travis.yml2
-rwxr-xr-x.travis/package_management/configure_deb_lxc_environment.py2
-rwxr-xr-x.travis/package_management/configure_rpm_lxc_environment.py2
-rw-r--r--packaging/installer/README.md8
-rwxr-xr-xpackaging/installer/install-required-packages.sh1772
-rwxr-xr-xpackaging/installer/kickstart.sh2
-rwxr-xr-xtests/updater_checks.sh2
7 files changed, 1781 insertions, 9 deletions
diff --git a/.travis.yml b/.travis.yml
index d5ee489762..328b44717d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -526,7 +526,7 @@ jobs:
name: Run coverity scan
before_script:
- - bash <(curl -sS https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh) --dont-wait --non-interactive netdata
+ - bash <(curl -sS https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh) --dont-wait --non-interactive netdata
- sudo apt-get install -y libjson-c-dev libipmimonitoring-dev libcups2-dev libsnappy-dev libprotobuf-dev libprotoc-dev libssl-dev protobuf-compiler
script: ./coverity-scan.sh --with-install
after_failure: post_message "TRAVIS_MESSAGE" "<!here> Coverity nightly run has failed" "${NOTIF_CHANNEL}"
diff --git a/.travis/package_management/configure_deb_lxc_environment.py b/.travis/package_management/configure_deb_lxc_environment.py
index 3c8a7689c9..6dee1a6b56 100755
--- a/.travis/package_management/configure_deb_lxc_environment.py
+++ b/.travis/package_management/configure_deb_lxc_environment.py
@@ -63,7 +63,7 @@ common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "libnet
common.run_command(container, [os.environ["REPO_TOOL"], "install", "-y", "libcups2-dev"])
print ("3.1 Run install-required-packages scriptlet")
-common.run_command(container, ["wget", "-T", "15", "-O", "%s/.install-required-packages.sh" % build_path, "https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh"])
+common.run_command(container, ["wget", "-T", "15", "-O", "%s/.install-required-packages.sh" % build_path, "https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh"])
common.run_command(container, ["bash", "%s/.install-required-packages.sh" % build_path, "netdata", "--dont-wait", "--non-interactive"])
print("3.2 Installing package dependencies within LXC container")
diff --git a/.travis/package_management/configure_rpm_lxc_environment.py b/.travis/package_management/configure_rpm_lxc_environment.py
index 79d34608fc..4dca0bf384 100755
--- a/.travis/package_management/configure_rpm_lxc_environment.py
+++ b/.travis/package_management/configure_rpm_lxc_environment.py
@@ -49,7 +49,7 @@ common.run_command(container, ["useradd", "-m", os.environ['BUILDER_NAME']])
print("2.1 Preparing repo on LXC container")
common.prepare_repo(container)
-common.run_command(container, ["wget", "-T", "15", "-O", "/home/%s/.install-required-packages.sh" % (os.environ['BUILDER_NAME']), "https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh"])
+common.run_command(container, ["wget", "-T", "15", "-O", "/home/%s/.install-required-packages.sh" % (os.environ['BUILDER_NAME']), "https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh"])
common.run_command(container, ["bash", "/home/%s/.install-required-packages.sh" % (os.environ['BUILDER_NAME']), "netdata", "--dont-wait", "--non-interactive"])
# Exceptional cases, not available everywhere
diff --git a/packaging/installer/README.md b/packaging/installer/README.md
index 1fcbcc6d4e..749641acf6 100644
--- a/packaging/installer/README.md
+++ b/packaging/installer/README.md
@@ -52,7 +52,7 @@ To learn more about the pros and cons of using *nightly* vs. *stable* releases,
Verify the integrity of the script with this:
```bash
-[ "0ae8dd3c4c9b976c4342c9fc09d9afae" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
+[ "952da7868b2c6b8819a7c600047400f5" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
```
_It should print `OK, VALID` if the script is the one we ship._
@@ -211,13 +211,13 @@ Try our experimental automatic requirements installer (no need to be root). This
Install the packages for having a **basic Netdata installation** (system monitoring and many applications, without `mysql` / `mariadb`, `postgres`, `named`, hardware sensors and `SNMP`):
```sh
-curl -Ss 'https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh' >/tmp/install-required-packages.sh && bash /tmp/install-required-packages.sh -i netdata
+curl -Ss 'https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh' >/tmp/install-required-packages.sh && bash /tmp/install-required-packages.sh -i netdata
```
Install all the required packages for **monitoring everything Netdata can monitor**:
```sh
-curl -Ss 'https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh' >/tmp/install-required-packages.sh && bash /tmp/install-required-packages.sh -i netdata-all
+curl -Ss 'https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh' >/tmp/install-required-packages.sh && bash /tmp/install-required-packages.sh -i netdata-all
```
If the above do not work for you, please [open a github issue](https://github.com/netdata/netdata/issues/new?title=packages%20installer%20failed&labels=installation%20help&body=The%20experimental%20packages%20installer%20failed.%0A%0AThis%20is%20what%20it%20says:%0A%0A%60%60%60txt%0A%0Aplease%20paste%20your%20screen%20here%0A%0A%60%60%60) with a copy of the message you get on screen. We are trying to make it work everywhere (this is also why the script [reports back](https://github.com/netdata/netdata/issues/2054) success or failure for all its runs).
@@ -567,7 +567,7 @@ curl -s https://api.github.com/repos/netdata/netdata/releases/latest | grep "bro
curl -s https://api.github.com/repos/netdata/netdata/releases/latest | grep "browser_download_url.*txt" | cut -d '"' -f 4 | wget -qi -
# Netdata dependency handling script
-curl -s https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh | wget -qi -
+curl -s https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh | wget -qi -
# go.d plugin
# For binaries for OS types and architectures not listed on [go.d releases](https://github.com/netdata/go.d.plugin/releases/latest), kindly open a github issue and we will do our best to serve your request
diff --git a/packaging/installer/install-required-packages.sh b/packaging/installer/install-required-packages.sh
new file mode 100755
index 0000000000..f7083eae11
--- /dev/null
+++ b/packaging/installer/install-required-packages.sh
@@ -0,0 +1,1772 @@
+#!/usr/bin/env bash
+
+export PATH="${PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+export LC_ALL=C
+
+# Be nice on production environments
+renice 19 $$ >/dev/null 2>/dev/null
+
+ME="${0}"
+
+if [ "${BASH_VERSINFO[0]}" -lt "4" ]
+then
+ echo >&2 "Sorry! This script needs BASH version 4+, but you have BASH version ${BASH_VERSION}"
+ exit 1
+fi
+
+# These options control which packages we are going to install
+# They can be pre-set, but also can be controlled with command line options
+PACKAGES_NETDATA=${PACKAGES_NETDATA-0}
+PACKAGES_NETDATA_NODEJS=${PACKAGES_NETDATA_NODEJS-0}
+PACKAGES_NETDATA_PYTHON=${PACKAGES_NETDATA_PYTHON-0}
+PACKAGES_NETDATA_PYTHON3=${PACKAGES_NETDATA_PYTHON3-0}
+PACKAGES_NETDATA_PYTHON_MYSQL=${PACKAGES_NETDATA_PYTHON_MYSQL-0}
+PACKAGES_NETDATA_PYTHON_POSTGRES=${PACKAGES_NETDATA_PYTHON_POSTGRES-0}
+PACKAGES_NETDATA_PYTHON_MONGO=${PACKAGES_NETDATA_PYTHON_MONGO-0}
+PACKAGES_DEBUG=${PACKAGES_DEBUG-0}
+PACKAGES_IPRANGE=${PACKAGES_IPRANGE-0}
+PACKAGES_FIREHOL=${PACKAGES_FIREHOL-0}
+PACKAGES_FIREQOS=${PACKAGES_FIREQOS-0}
+PACKAGES_UPDATE_IPSETS=${PACKAGES_UPDATE_IPSETS-0}
+PACKAGES_NETDATA_DEMO_SITE=${PACKAGES_NETDATA_DEMO_SITE-0}
+PACKAGES_NETDATA_SENSORS=${PACKAGES_NETDATA_SENSORS-0}
+PACKAGES_NETDATA_DATABASE=${PACKAGES_NETDATA_DATABASE-0}
+
+# needed commands
+lsb_release=$(which lsb_release 2>/dev/null || command -v lsb_release 2>/dev/null)
+
+# Check which package managers are available
+apk=$(which apk 2>/dev/null || command -v apk 2>/dev/null)
+apt_get=$(which apt-get 2>/dev/null || command -v apt-get 2>/dev/null)
+dnf=$(which dnf 2>/dev/null || command -v dnf 2>/dev/null)
+emerge=$(which emerge 2>/dev/null || command -v emerge 2>/dev/null)
+equo=$(which equo 2>/dev/null || command -v equo 2>/dev/null)
+pacman=$(which pacman 2>/dev/null || command -v pacman 2>/dev/null)
+yum=$(which yum 2>/dev/null || command -v yum 2>/dev/null)
+zypper=$(which zypper 2>/dev/null || command -v zypper 2>/dev/null)
+
+distribution=
+version=
+codename=
+package_installer=
+tree=
+detection=
+NAME=
+ID=
+ID_LIKE=
+VERSION=
+VERSION_ID=
+
+usage() {
+ cat <<EOF
+OPTIONS:
+
+${ME} [--dont-wait] [--non-interactive] \\
+ [distribution DD [version VV] [codename CN]] [installer IN] [packages]
+
+Supported distributions (DD):
+
+ - arch (all Arch Linux derivatives)
+ - centos (all CentOS derivatives)
+ - gentoo (all Gentoo Linux derivatives)
+ - sabayon (all Sabayon Linux derivatives)
+ - debian, ubuntu (all Debian and Ubuntu derivatives)
+ - redhat, fedora (all Red Hat and Fedora derivatives)
+ - suse, opensuse (all SuSe and openSuSe derivatives)
+
+Supported installers (IN):
+
+ - apt-get all Debian / Ubuntu Linux derivatives
+ - dnf newer Red Hat / Fedora Linux
+ - emerge all Gentoo Linux derivatives
+ - equo all Sabayon Linux derivatives
+ - pacman all Arch Linux derivatives
+ - yum all Red Hat / Fedora / CentOS Linux derivatives
+ - zypper all SuSe Linux derivatives
+ - apk all Alpine derivatives
+
+Supported packages (you can append many of them):
+
+ - netdata-all all packages required to install netdata
+ including mysql client, postgres client,
+ node.js, python, sensors, etc
+
+ - netdata minimum packages required to install netdata
+ (no mysql client, no nodejs, includes python)
+
+ - nodejs install nodejs
+ (required for monitoring named and SNMP)
+
+ - python install python
+
+ - python3 install python3
+
+ - python-mysql install MySQLdb
+ (for monitoring mysql, will install python3 version
+ if python3 is enabled or detected)
+
+ - python-postgres install psycopg2
+ (for monitoring postgres, will install python3 version
+ if python3 is enabled or detected)
+
+ - python-pymongo install python-pymongo (or python3-pymongo for python3)
+
+ - sensors install lm_sensors for monitoring h/w sensors
+
+ - firehol-all packages required for FireHOL, FireQoS, update-ipsets
+ - firehol packages required for FireHOL
+ - fireqos packages required for FireQoS
+ - update-ipsets packages required for update-ipsets
+
+ - demo packages required for running a netdata demo site
+ (includes nginx and various debugging tools)
+
+
+If you don't supply the --dont-wait option, the program
+will ask you before touching your system.
+
+EOF
+}
+
+release2lsb_release() {
+ # loads the given /etc/x-release file
+ # this file is normaly a single line containing something like
+ #
+ # X Linux release 1.2.3 (release-name)
+ #
+ # It attempts to parse it
+ # If it succeeds, it returns 0
+ # otherwise it returns 1
+
+ local file="${1}" x DISTRIB_ID= DISTRIB_RELEASE= DISTRIB_CODENAME= DISTRIB_DESCRIPTION=
+ echo >&2 "Loading ${file} ..."
+
+
+ x="$(cat "${file}" | grep -v "^$" | head -n 1)"
+
+ if [[ "${x}" =~ ^.*[[:space:]]+Linux[[:space:]]+release[[:space:]]+.*[[:space:]]+(.*)[[:space:]]*$ ]]
+ then
+ eval "$(echo "${x}" | sed "s|^\(.*\)[[:space:]]\+Linux[[:space:]]\+release[[:space:]]\+\(.*\)[[:space:]]\+(\(.*\))[[:space:]]*$|DISTRIB_ID=\"\1\"\nDISTRIB_RELEASE=\"\2\"\nDISTRIB_CODENAME=\"\3\"|g" | grep "^DISTRIB")"
+ elif [[ "${x}" =~ ^.*[[:space:]]+Linux[[:space:]]+release[[:space:]]+.*[[:space:]]+$ ]]
+ then
+ eval "$(echo "${x}" | sed "s|^\(.*\)[[:space:]]\+Linux[[:space:]]\+release[[:space:]]\+\(.*\)[[:space:]]*$|DISTRIB_ID=\"\1\"\nDISTRIB_RELEASE=\"\2\"|g" | grep "^DISTRIB")"
+ elif [[ "${x}" =~ ^.*[[:space:]]+release[[:space:]]+.*[[:space:]]+(.*)[[:space:]]*$ ]]
+ then
+ eval "$(echo "${x}" | sed "s|^\(.*\)[[:space:]]\+release[[:space:]]\+\(.*\)[[:space:]]\+(\(.*\))[[:space:]]*$|DISTRIB_ID=\"\1\"\nDISTRIB_RELEASE=\"\2\"\nDISTRIB_CODENAME=\"\3\"|g" | grep "^DISTRIB")"
+ elif [[ "${x}" =~ ^.*[[:space:]]+release[[:space:]]+.*[[:space:]]+$ ]]
+ then
+ eval "$(echo "${x}" | sed "s|^\(.*\)[[:space:]]\+release[[:space:]]\+\(.*\)[[:space:]]*$|DISTRIB_ID=\"\1\"\nDISTRIB_RELEASE=\"\2\"|g" | grep "^DISTRIB")"
+ fi
+
+ distribution="${DISTRIB_ID}"
+ version="${DISTRIB_RELEASE}"
+ codename="${DISTRIB_CODENAME}"
+
+ [ -z "${distribution}" ] && echo >&2 "Cannot parse this lsb-release: ${x}" && return 1
+ detection="${file}"
+ return 0
+}
+
+get_os_release() {
+ # Loads the /etc/os-release file
+ # Only the required fields are loaded
+ #
+ # If it manages to load /etc/os-release, it returns 0
+ # otherwise it returns 1
+ #
+ # It searches the ID_LIKE field for a compatible distribution
+
+ local x
+ if [ -f "/etc/os-release" ]
+ then
+ echo >&2 "Loading /etc/os-release ..."
+
+ eval "$(cat /etc/os-release | grep -E "^(NAME|ID|ID_LIKE|VERSION|VERSION_ID)=")"
+ for x in "${ID}" ${ID_LIKE}
+ do
+ case "${x,,}" in
+ alpine|arch|centos|debian|fedora|gentoo|sabayon|rhel|ubuntu|suse|opensuse-leap|sles)
+ distribution="${x}"
+ version="${VERSION_ID}"
+ codename="${VERSION}"
+ detection="/etc/os-release"
+ break
+ ;;
+ *)
+ echo >&2 "Unknown distribution ID: ${x}"
+ ;;
+ esac
+ done
+ [ -z "${distribution}" ] && echo >&2 "Cannot find valid distribution in: ${ID} ${ID_LIKE}" && return 1
+ else
+ echo >&2 "Cannot find /etc/os-release" && return 1
+ fi
+
+ [ -z "${distribution}" ] && return 1
+ return 0
+}
+
+get_lsb_release() {
+ # Loads the /etc/lsb-release file
+ # If it fails, it attempts to run the command: lsb_release -a
+ # and parse its output
+ #
+ # If it manages to find the lsb-release, it returns 0
+ # otherwise it returns 1
+
+ if [ -f "/etc/lsb-release" ]
+ then
+ echo >&2 "Loading /etc/lsb-release ..."
+ local DISTRIB_ID= ISTRIB_RELEASE= DISTRIB_CODENAME= DISTRIB_DESCRIPTION=
+ eval "$(cat /etc/lsb-release | grep -E "^(DISTRIB_ID|DISTRIB_RELEASE|DISTRIB_CODENAME)=")"
+ distribution="${DISTRIB_ID}"
+ version="${DISTRIB_RELEASE}"
+ codename="${DISTRIB_CODENAME}"
+ detection="/etc/lsb-release"
+ fi
+
+ if [ -z "${distribution}" -a ! -z "${lsb_release}" ]
+ then
+ echo >&2 "Cannot find distribution with /etc/lsb-release"
+ echo >&2 "Running command: lsb_release ..."
+ eval "declare -A release=( $(lsb_release -a 2>/dev/null | sed -e "s|^\(.*\):[[:space:]]*\(.*\)$|[\1]=\"\2\"|g") )"
+ distribution="${release[Distributor ID]}"
+ version="${release[Release]}"
+ codename="${release[Codename]}"
+ detection="lsb_release"
+ fi
+
+ [ -z "${distribution}" ] && echo >&2 "Cannot find valid distribution with lsb-release" && return 1
+ return 0
+}
+
+find_etc_any_release() {
+ # Check for any of the known /etc/x-release files
+ # If it finds one, it loads it and returns 0
+ # otherwise it returns 1
+
+ if [ -f "/etc/arch-release" ]
+ then
+ release2lsb_release "/etc/arch-release" && return 0
+ fi
+
+ if [ -f "/etc/centos-release" ]
+ then
+ release2lsb_release "/etc/centos-release" && return 0
+ fi
+
+ if [ -f "/etc/redhat-release" ]
+ then
+ release2lsb_release "/etc/redhat-release" && return 0
+ fi
+
+ if [ -f "/etc/SuSe-release" ]
+ then
+ release2lsb_release "/etc/SuSe-release" && return 0
+ fi
+
+ return 1
+}
+
+autodetect_distribution() {
+ # autodetection of distribution
+ get_os_release || get_lsb_release || find_etc_any_release
+}
+
+user_picks_distribution() {
+ # let the user pick a distribution
+
+ echo >&2
+ echo >&2 "I NEED YOUR HELP"
+ echo >&2 "It seems I cannot detect your system automatically."
+ if [ -z "${equo}" -a -z "${emerge}" -a -z "${apt_get}" -a -z "${yum}" -a -z "${dnf}" -a -z "${pacman}" -a -z "${apk}" ]
+ then
+ echo >&2 "And it seems I cannot find a known package manager in this system."
+ echo >&2 "Please open a github issue to help us support your system too."
+ exit 1
+ fi
+
+ local opts=
+ echo >&2 "I found though that the following installers are available:"
+ echo >&2
+ [ ! -z "${apt_get}" ] && echo >&2 " - Debian/Ubuntu based (installer is: apt-get)" && opts="apt-get ${opts}"
+ [ ! -z "${yum}" ] && echo >&2 " - Redhat/Fedora/Centos based (installer is: yum)" && opts="yum ${opts}"
+ [ ! -z "${dnf}" ] && echo >&2 " - Redhat/Fedora/Centos based (installer is: dnf)" && opts="dnf ${opts}"
+ [ ! -z "${zypper}" ] && echo >&2 " - SuSe based (installer is: zypper)" && opts="zypper ${opts}"
+ [ ! -z "${pacman}" ] && echo >&2 " - Arch Linux based (installer is: pacman)" && opts="pacman ${opts}"
+ [ ! -z "${emerge}" ] && echo >&2 " - Gentoo based (installer is: emerge)" && opts="emerge ${opts}"
+ [ ! -z "${equo}" ] && echo >&2 " - Sabayon based (installer is: equo)" && opts="equo ${opts}"
+ [ ! -z "${apk}" ] && echo >&2 " - Alpine Linux based (installer is: apk)" && opts="apk ${opts}"
+ echo >&2
+
+ REPLY=
+ while [ -z "${REPLY}" ]
+ do
+ echo "To proceed please write one of these:"
+ echo "${opts}" | sed -e 's/ /, /g'
+ read -p ">" REPLY
+ [ $? -ne 0 ] && REPLY= && continue
+
+ if [ "${REPLY}" = "yum" -a -z "${distribution}" ]
+ then
+ REPLY=
+ while [ -z "${REPLY}" ]
+ do
+ read -p "yum in centos, rhel or fedora? > "
+ [ $? -ne 0 ] && continue
+
+ case "${REPLY,,}" in
+ fedora|rhel)
+ distribution="rhel"
+ ;;
+ centos)
+ distribution="centos"
+ ;;
+ *)
+ echo >&2 "Please enter 'centos', 'fedora' or 'rhel'."
+ REPLY=
+ ;;
+ esac
+ done
+ REPLY="yum"
+ fi
+ check_package_manager "${REPLY}" || REPLY=
+ done
+}
+
+detect_package_manager_from_distribution() {
+ case "${1,,}" in
+ arch*|manjaro*)
+ package_installer="install_pacman"
+ tree="arch"
+ if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${pacman}" ]
+ then
+ echo >&2 "command 'pacman' is required to install packages on a '${distribution} ${version}' system."
+ exit 1
+ fi
+ ;;
+
+ sabayon*)
+ package_installer="install_equo"
+ tree="sabayon"
+ if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${equo}" ]
+ then
+ echo >&2 "command 'equo' is required to install packages on a '${distribution} ${version}' system."
+ # Maybe offer to fall back on emerge? Both installers exist in Sabayon...
+ exit 1
+ fi
+ ;;
+
+ alpine*)
+ package_installer="install_apk"
+ tree="alpine"
+ if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${apk}" ]
+ then
+ echo >&2 "command 'apk' is required to install packages on a '${distribution} ${version}' system."
+ exit 1
+ fi
+ ;;
+
+ gentoo*)
+ package_installer="install_emerge"
+ tree="gentoo"
+ if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${emerge}" ]
+ then
+ echo >&2 "command 'emerge' is required to install packages on a '${distribution} ${version}' system."
+ exit 1
+ fi
+ ;;
+
+ debian*|ubuntu*)
+ package_installer="install_apt_get"
+ tree="debian"
+ if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${apt_get}" ]
+ then
+ echo >&2 "command 'apt-get' is required to install packages on a '${distribution} ${version}' system."
+ exit 1
+ fi
+ ;;
+
+ centos*|clearos*)
+ echo >&2 "You should have EPEL enabled to install all the prerequisites."
+ echo >&2 "Check: http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/"
+ package_installer="install_yum"
+ tree="centos"
+ if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${yum}" ]
+ then
+ echo >&2 "command 'yum' is required to install packages on a '${distribution} ${version}' system."
+ exit 1
+ fi
+ ;;
+
+ fedora*|redhat*|red\ hat*|rhel*)
+ package_installer=
+ tree="rhel"
+ [ ! -z "${yum}" ] && package_installer="install_yum"
+ [ ! -z "${dnf}" ] && package_installer="install_dnf"
+ if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${package_installer}" ]
+ then
+ echo >&2 "command 'yum' or 'dnf' is required to install packages on a '${distribution} ${version}' system."
+ exit 1
+ fi
+ ;;
+
+ suse*|opensuse*|sles*)
+ package_installer="install_zypper"
+ tree="suse"
+ if [ ${IGNORE_INSTALLED} -eq 0 -a -z "${zypper}" ]
+ then
+ echo >&2 "command 'zypper' is required to install packages on a '${distribution} ${version}' system."
+ exit 1
+ fi
+ ;;
+
+ *)
+ # oops! unknown system
+ user_picks_distribution
+ ;;
+ esac
+}
+
+check_package_manager() {
+ # This is called only when the user is selecting a package manager
+ # It is used to verify the user selection is right
+
+ echo >&2 "Checking package manager: ${1}"
+
+ case "${1}" in
+ apt-get)
+ [ ${IGNORE_INSTALLED} -eq 0 -a -z "${apt_get}" ] && echo >&2 "${1} is not available." && return 1
+ package_installer="install_apt_get"
+ tree="debian"
+ detection="user-input"
+ return 0
+ ;;
+
+ dnf)
+ [ ${IGNORE_INSTALLED} -eq 0 -a -z "${dnf}" ] && echo >&2 "${1} is not available." && return 1
+ package_installer="install_dnf"
+ tree="rhel"
+ detection="user-input"
+ return 0
+ ;;
+
+ apk)
+ [ ${IGNORE_INSTALLED} -eq 0 -a -z "${apk}" ] && echo >&2 "${1} is not available." && return 1
+ package_installer="install_apk"
+ tree="alpine"
+ detection="user-input"
+ return 0
+ ;;
+
+ equo)
+ [ ${IGNORE_INSTALLED} -eq 0 -a -z "${equo}" ] && echo >&2 "${1} is not available." && return 1
+ package_installer="install_equo"
+ tree="sabayon"
+ detection="user-input"
+ return 0
+ ;;
+
+ emerge)
+ [ ${IGNORE_INSTALLED} -eq 0 -a -z "${emerge}" ] && echo >&2 "${1} is not available." && return 1
+ package_installer="install_emerge"
+ tree="gentoo"
+ detection="user-input"
+ return 0
+ ;;
+
+ pacman)
+ [ ${IGNORE_INSTALLED} -eq 0 -a -z "${pacman}" ] && echo >&2 "${1} is not available." && return 1
+ package_installer="install_pacman"
+ tree="arch"
+ detection="user-input"
+
+ return 0
+ ;;
+
+ zypper)
+ [ ${IGNORE_INSTALLED} -eq 0 -a -z "${zypper}" ] && echo >&2 "${1} is not available." && return 1
+ package_installer="install_zypper"
+ tree="suse"
+ detection="user-input"
+ return 0
+ ;;
+
+ yum)
+ [ ${IGNORE_INSTALLED} -eq 0 -a -z "${yum}" ] && echo >&2 "${1} is not available." && return 1
+ package_installer="install_yum"
+ if [ "${distribution}" = "centos" ]
+ then
+ tree="centos"
+ else
+ tree="rhel"
+ fi
+ detection="user-input"
+ return 0
+ ;;
+
+ *)
+ echo >&2 "Invalid package manager: '${1}'."
+ return 1
+ ;;
+ esac
+}
+
+require_cmd() {
+ # check if any of the commands given as argument
+ # are present on this system
+ # If any of them is available, it returns 0
+ # otherwise 1
+
+ [ ${IGNORE_INSTALLED} -eq 1 ] && return 1
+
+ local wanted found
+ for wanted in "${@}"
+ do
+ found="$(which "${wanted}" 2>/dev/null)"
+ [ -z "${found}" ] && found="$(command -v "${wanted}" 2>/dev/null)"
+ [ ! -z "${found}" -a -x "${found}" ] && return 0
+ done
+
+ return 1
+}
+
+declare -A pkg_find=(
+ ['fedora']="findutils"
+ ['default']="WARNING|"
+)
+
+declare -A pkg_distro_sdk=(
+ ['alpine']="alpine-sdk"
+ ['default']="NOTREQUIRED"
+ )
+
+declare -A pkg_autoconf=(
+ ['gentoo']="sys-devel/autoconf"
+ ['default']="autoconf"
+ )
+
+# required to compile netdata with --enable-sse
+# https://github.com/firehol/netdata/pull/450
+declare -A pkg_autoconf_archive=(
+ ['gentoo']="sys-devel/autoconf-archive"
+ ['alpine']="WARNING|"
+ ['default']="autoconf-archive"
+
+ # exceptions
+ ['centos-6']="WARNING|"
+ ['rhel-6']="WARNING|"
+ ['rhel-7']="WARNING|"
+ )
+
+declare -A pkg_autogen=(
+ ['gentoo']="sys-devel/autogen"
+ ['alpine']="WARNING|"
+ ['default']="autogen"
+
+ # exceptions
+ ['centos-6']="WARNING|"
+ ['rhel-6']="WARNING|"
+ ['ubuntu-18']="WARNING|"
+ )
+
+declare -A pkg_automake=(
+ ['gentoo']="sys-devel/automake"
+ ['default']="automake"
+ )
+
+declare -A pkg_bridge_utils=(
+ ['gentoo']="net-misc/bridge-utils"
+ ['default']="bridge-utils"
+ )
+
+declare -A pkg_chrony=(
+ ['default']="chrony"
+ )
+
+declare -A pkg_curl=(
+ ['gentoo']="net-misc/curl"
+ ['sabayon']="net-misc/curl"
+ ['default']="curl"
+ )
+
+declare -A pkg_gzip=(
+ ['default']="gzip"
+)
+
+declare -A pkg_tar=(
+ ['default']="tar"
+ )
+
+declare -A pkg_git=(
+ ['gentoo']="dev-vcs/git"
+ ['default']="git"
+ )
+
+declare -A pkg_gcc=(
+ ['gentoo']="sys-devel/gcc"
+ ['default']="gcc"
+ )
+
+declare -A pkg_gdb=(
+ ['gentoo']="sys-devel/gdb"
+ ['default']="gdb"
+ )
+
+declare -A pkg_iotop=(
+ ['default']="iotop"
+ )
+
+declare -A pkg_iproute2=(
+ ['alpine']="iproute2"
+ ['debian']="iproute2"
+ ['gentoo']="sys-apps/iproute2"
+ ['sabayon']="sys-apps/iproute2"
+ ['default']="iproute"
+
+ # exceptions
+ ['ubuntu-12.04']="iproute"
+ )
+
+declare -A pkg_ipset=(
+ ['gentoo']="net-firewall/ipset"
+ ['default']="ipset"
+ )
+
+declare -A pkg_jq=(
+ ['gentoo']="app-misc/jq"
+ ['default']="jq"
+ )
+
+declare -A pkg_iptables=(
+ ['gentoo']="net-firewall/iptables"
+ ['default']="iptables"
+ )
+
+declare -A pkg_libz_dev=(
+ ['alpine']="zlib-dev"
+ ['arch']="zlib"
+ ['centos']="zlib-devel"
+ ['debian']="zlib1g-dev"
+ ['gentoo']="sys-libs/zlib"
+ ['sabayon']="sys-libs/zlib"
+ ['rhel']="zlib-devel"
+ ['suse']="zlib-devel"
+ ['default']=""
+ )
+
+declare -A pkg_libuuid_dev=(
+ ['alpine']="util-linux-dev"
+ ['arch']="util-linux"
+ ['centos']="libuuid-devel"
+ ['debian']="uuid-dev"
+ ['gentoo']="sys-apps/util-linux"
+ ['sabayon']="sys-apps/util-linux"
+ ['rhel']="libuuid-devel"
+ ['suse']="libuuid-devel"
+ ['default']=""
+ )
+
+declare -A pkg_libmnl_dev=(
+ ['alpine']="libmnl-dev"
+ ['arch']="libmnl"
+ ['centos']="libmnl-devel"
+ ['debian']="libmnl-dev"
+ ['gentoo']="net-libs/libmnl"
+ ['sabayon']="net-libs/libmnl"
+ ['rhel']="libmnl-devel"
+ ['suse']="libmnl-devel"
+ ['default']=""
+ )
+
+declare -A pkg_lm_sensors=(
+ ['alpine']="lm_sensors"
+ ['arch']="lm_sensors"
+ ['centos']="lm_sensors"
+ ['debian']="lm-sensors"
+ ['gentoo']="sys-apps/lm_sensors"
+ ['sabayon']="sys-apps/lm_sensors"
+ ['rhel']="lm_sensors"
+ ['suse']="sensors"
+ ['default']="lm_sensors"
+ )
+
+declare -A pkg_logwatch=(
+ ['default']="logwatch"
+ )
+
+declare -A pkg_lxc=(
+ ['default']="lxc"
+ )
+
+declare -A pkg_mailutils=(
+ ['default']="mailutils"
+ )
+
+declare -A pkg_make=(
+ ['gentoo']="sys-devel/make"
+ ['default']="make"
+ )
+
+declare -A pkg_netcat=(
+ ['alpine']="netcat-openbsd"
+ ['arch']="netcat"
+ ['centos']="nmap-ncat"
+ ['debian']="netcat"
+ ['gentoo']="net-analyzer/netcat"
+ ['sabayon']="net-analyzer/gnu-netcat"
+ ['rhel']="nmap-ncat"
+ ['suse']="netcat-openbsd"
+ ['default']="netcat"
+
+ # exceptions
+ ['centos-6']="nc"
+ ['rhel-6']="nc"
+ )
+
+declare -A pkg_nginx=(
+ ['gentoo']="www-servers/nginx"
+ ['default']="nginx"
+ )
+
+declare -A pkg_nodejs=(
+ ['gentoo']="net-libs/nodejs"
+ ['default']="nodejs"
+
+ # exceptions
+ ['rhel-6']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
+ ['rhel-7']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
+ ['centos-6']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
+ ['debian-6']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
+ ['debian-7']="WARNING|To install nodejs check: https://nodejs.org/en/download/package-manager/"
+ )
+
+declare -A pkg_postfix=(
+ ['default']="postfix"
+ )
+
+declare -A pkg_pkg_config=(
+ ['alpine']="pkgconfig"
+ ['arch']="pkgconfig"
+ ['centos']="pkgconfig"
+ ['debian']="pkg-config"
+ ['gentoo']="dev-util/pkgconfig"
+ ['sabayon']="virtual/pkgconfig"
+ ['rhel']="pkgconfig"
+ ['suse']="pkg-config"
+ ['default']="pkg-config"
+ )
+
+declare -A pkg_python=(
+ ['gentoo']="dev-lang/python"
+ ['sabayon']="dev-lang/python:2.7"
+ ['default']="python"
+
+ # Exceptions
+ ['centos-8']="python2"
+ )
+
+declare -A pkg_python_mysqldb=(
+ ['alpine']="py-mysqldb"
+ ['arch']="mysql-python"
+ ['centos']="MySQL-python"
+ ['debian']="python-mysqldb"
+ ['gentoo']="dev-python/mysqlclient"
+ ['sabayon']="dev-python/mysqlclient"
+ ['rhel']="MySQL-python"
+ ['suse']="python-PyMySQL"
+ ['default']="python-mysql"
+
+ # exceptions
+ ['fedora-24']="python2-mysql"
+ )
+
+declare -A pkg_python3_mysqldb=(
+ ['alpine']="WARNING|"
+ ['arch']="WARNING|"
+ ['centos']="WARNING|"
+ ['debian']="python3-mysqldb"
+ ['gentoo']="dev-python/mysqlclient"
+ ['sabayon']="dev-python/mysqlclient"
+ ['rhel']="WARNING|"
+ ['suse']="WARNING|"
+ ['default']="WARNING|"
+
+ # exceptions
+ ['debian-6']="WARNING|"
+ ['debian-7']="WARNING|"
+ ['debian-8']="WARNING|"
+ ['ubuntu-12.04']="WARNING|"
+ ['ubuntu-12.10']="WARNING|"
+ ['ubuntu-13.04']="WARNING|"
+ ['ubuntu-13.10']="WARNING|"
+ ['ubuntu-14.04']="WARNING|"
+ ['ubuntu-14.10']="WARNING|"
+ ['ubuntu-15.04']="WARNING|"
+ ['ubuntu-15.10']="WARNING|"
+ )
+
+declare -A pkg_python_psycopg2=(
+ ['alpine']="py-psycopg2"
+ ['arch']="python2-psycopg2"
+ ['centos']="python-psycopg2"
+ ['debian']="python-psycopg2"
+ ['gentoo']="dev-python/psycopg"
+ ['sabayon']="dev-python/psycopg:2"
+ ['rhel']="python-psycopg2"
+ ['suse']="python-psycopg2"
+ ['default']="python-psycopg2"
+ )
+
+declare -A pkg_python3_psycopg2=(
+ ['alpine']="py3-psycopg2"
+ ['arch']="python-psycopg2"
+ ['centos']="WARNING|"
+ ['debian']="WARNING|"
+ ['gentoo']="dev-python/psycopg"
+ ['sabayon']="dev-python/psycopg:2"
+ ['rhel']="WARNING|"
+ ['suse']="WARNING|"
+ ['default']="WARNING|"
+ )
+
+declare -A pkg_python_pip=(
+ ['alpine']="py-pip"
+ ['gentoo']="dev-python/pip"
+ ['sabayon']="dev-python/pip"
+ ['default']="python-pip"
+ )
+
+declare -A pkg_python3_pip=(
+ ['alpine']="py3-pip"
+ ['arch']="python-pip"
+ ['centos']="WARNING|"
+ ['gentoo']="dev-python/pip"
+ ['sabayon']="dev-python/pip"
+ ['rhel']="WARNING|"
+ ['default']="python3-pip"
+ )
+
+declare -A pkg_python_pymongo=(
+ ['alpine']="WARNING|"
+ ['arch']="python2-pymongo"
+ ['centos']="WARNING|"
+ ['debian']="python-pymongo"
+ ['gentoo']="dev-python/pymongo"
+ ['suse']="python-pymongo"
+ ['default']="python-pymongo"
+ )
+
+declare -A pkg_python3_pymongo=(
+ ['alpine']="WARNING|"
+ ['arch']="python-pymongo"
+ ['centos']="WARNING|"
+ ['debian']="python3-pymongo"
+ ['gentoo']="dev-python/pymongo"
+ ['suse']="python3-pymongo"
+ ['default']="python3-pymongo"
+ )
+
+declare -A pkg_python_requests=(
+ ['alpine']="py-requests"