@cryptotaxi247 / netdata-1 / commits / d49e6b50b

Added various fixes and improvements to the installers. (#8315)

* Don't rotate old Netdata config dirs in static installer. This should have been removed when we stopped shipping stock configs in `/etc/netdata`. * Use a single invocation of the package manager to install dependencies. This slightly improves the efficiency of the code in question, and also eliminates a few dozen potential cases of prompting the user if they want to install specific packages. * Add correct package name for ulogd on arch. * Properly finish conversion to Python 3 defaults.

Austin S. Hemmelgarn committed Mar 9, 2020 at 11:15 UTC d49e6b50ba4a9ff2237685345acf3ded0dbe7a74
2 files changed +66 -56
packaging/installer/install-required-packages.sh
+63 -52
@@ -1032,6 +1032,7 @@ declare -A pkg_ulogd=(
1032 ['rhel']="WARNING|"
1033 ['clearlinux']="WARNING|"
1034 ['gentoo']="app-admin/ulogd"
1035 + ['arch']="ulogd"
1036 ['default']="ulogd2"
1037 )
1038
@@ -1283,10 +1284,7 @@ install_apt_get() {
1284 read -r -a apt_opts <<< "$opts"
1285
1286 # install the required packages
1286 - for pkg in "${@}"; do
1287 - [[ ${DRYRUN} -eq 0 ]] && echo >&2 "Adding package ${pkg}"
1288 - run ${sudo} apt-get "${apt_opts[@]}" install "${pkg}"
1289 - done
1287 + run ${sudo} apt-get "${apt_opts[@]}" install "${@}"
1288 }
1289
1290 # -----------------------------------------------------------------------------
@@ -1450,10 +1448,7 @@ install_emerge() {
1448 read -r -a emerge_opts <<< "$opts"
1449
1450 # install the required packages
1453 - for pkg in "${@}"; do
1454 - [[ ${DRYRUN} -eq 0 ]] && echo >&2 "Adding package ${pkg}"
1455 - run ${sudo} emerge "${emerge_opts[@]}" -v --noreplace "${pkg}"
1456 - done
1451 + run ${sudo} emerge "${emerge_opts[@]}" -v --noreplace "${@}"
1452 }
1453
1454 # -----------------------------------------------------------------------------
@@ -1511,10 +1506,7 @@ install_equo() {
1506 read -r -a equo_opts <<< "$opts"
1507
1508 # install the required packages
1514 - for pkg in "${@}"; do
1515 - [[ ${DRYRUN} -eq 0 ]] && echo >&2 "Adding package ${pkg}"
1516 - run ${sudo} equo i "${equo_opts[@]}" "${pkg}"
1517 - done
1509 + run ${sudo} equo i "${equo_opts[@]}" "${@}"
1510 }
1511
1512 # -----------------------------------------------------------------------------
@@ -1570,17 +1562,10 @@ install_pacman() {
1562 if [ "${NON_INTERACTIVE}" -eq 1 ]; then
1563 echo >&2 "Running in non-interactive mode"
1564 # http://unix.stackexchange.com/questions/52277/pacman-option-to-assume-yes-to-every-question/52278
1573 - for pkg in "${@}"; do
1574 - [[ ${DRYRUN} -eq 0 ]] && echo >&2 "Adding package ${pkg}"
1575 - # Try the noconfirm option, if that fails, go with the legacy way for non-interactive
1576 - run ${sudo} pacman --noconfirm --needed -S "${pkg}" || yes | run ${sudo} pacman --needed -S "${pkg}"
1577 - done
1578 -
1565 + # Try the noconfirm option, if that fails, go with the legacy way for non-interactive
1566 + run ${sudo} pacman --noconfirm --needed -S "${@}" || yes | run ${sudo} pacman --needed -S "${@}"
1567 else
1580 - for pkg in "${@}"; do
1581 - [[ ${DRYRUN} -eq 0 ]] && echo >&2 "Adding package ${pkg}"
1582 - run ${sudo} pacman --needed -S "${pkg}"
1583 - done
1568 + run ${sudo} pacman --needed -S "${@}"
1569 fi
1570 }
1571
@@ -1675,6 +1660,17 @@ if [ -z "${1}" ]; then
1660 exit 1
1661 fi
1662
1663 +pv=$(python --version 2>&1)
1664 +if [[ "${pv}" =~ ^Python\ 2.* ]]; then
1665 + pv=2
1666 +elif [[ "${pv}" =~ ^Python\ 3.* ]]; then
1667 + pv=3
1668 +elif [[ "${tree}" == "centos" ]] && [ "${version}" -lt 8 ]; then
1669 + pv=2
1670 +else
1671 + pv=3
1672 +fi
1673 +
1674 # parse command line arguments
1675 DONT_WAIT=0
1676 NON_INTERACTIVE=0
@@ -1716,17 +1712,24 @@ while [ -n "${1}" ]; do
1712 netdata-all)
1713 PACKAGES_NETDATA=1
1714 PACKAGES_NETDATA_NODEJS=1
1719 - PACKAGES_NETDATA_PYTHON=1
1720 - PACKAGES_NETDATA_PYTHON_MYSQL=1
1721 - PACKAGES_NETDATA_PYTHON_POSTGRES=1
1722 - PACKAGES_NETDATA_PYTHON_MONGO=1
1715 + if [ "${pv}" -eq 2 ] ; then
1716 + PACKAGES_NETDATA_PYTHON=1
1717 + PACKAGES_NETDATA_PYTHON_MYSQL=1
1718 + PACKAGES_NETDATA_PYTHON_POSTGRES=1
1719 + PACKAGES_NETDATA_PYTHON_MONGO=1
1720 + else
1721 + PACKAGES_NETDATA_PYTHON3=1
1722 + PACKAGES_NETDATA_PYTHON3_MYSQL=1
1723 + PACKAGES_NETDATA_PYTHON3_POSTGRES=1
1724 + PACKAGES_NETDATA_PYTHON3_MONGO=1
1725 + fi
1726 PACKAGES_NETDATA_SENSORS=1
1727 PACKAGES_NETDATA_DATABASE=1
1728 ;;
1729
1730 netdata)
1731 PACKAGES_NETDATA=1
1729 - PACKAGES_NETDATA_PYTHON=1
1732 + PACKAGES_NETDATA_PYTHON3=1
1733 PACKAGES_NETDATA_DATABASE=1
1734 ;;
1735
@@ -1739,18 +1742,33 @@ while [ -n "${1}" ]; do
1742 ;;
1743
1744 python-mysql | mysql-python | mysqldb | netdata-mysql)
1742 - PACKAGES_NETDATA_PYTHON=1
1743 - PACKAGES_NETDATA_PYTHON_MYSQL=1
1745 + if [ "${pv}" -eq 2 ] ; then
1746 + PACKAGES_NETDATA_PYTHON=1
1747 + PACKAGES_NETDATA_PYTHON_MYSQL=1
1748 + else
1749 + PACKAGES_NETDATA_PYTHON3=1
1750 + PACKAGES_NETDATA_PYTHON3_MYSQL=1
1751 + fi
1752 ;;
1753
1754 python-postgres | postgres-python | psycopg2 | netdata-postgres)
1747 - PACKAGES_NETDATA_PYTHON=1
1748 - PACKAGES_NETDATA_PYTHON_POSTGRES=1
1755 + if [ "${pv}" -eq 2 ] ; then
1756 + PACKAGES_NETDATA_PYTHON=1
1757 + PACKAGES_NETDATA_PYTHON_POSTGRES=1
1758 + else
1759 + PACKAGES_NETDATA_PYTHON3=1
1760 + PACKAGES_NETDATA_PYTHON3_POSTGRES=1
1761 + fi
1762 ;;
1763
1764 python-pymongo)
1752 - PACKAGES_NETDATA_PYTHON=1
1753 - PACKAGES_NETDATA_PYTHON_MONGO=1
1765 + if [ "${pv}" -eq 2 ] ; then
1766 + PACKAGES_NETDATA_PYTHON=1
1767 + PACKAGES_NETDATA_PYTHON_MONGO=1
1768 + else
1769 + PACKAGES_NETDATA_PYTHON3=1
1770 + PACKAGES_NETDATA_PYTHON3_MONGO=1
1771 + fi
1772 ;;
1773
1774 nodejs | netdata-nodejs)
@@ -1761,7 +1779,7 @@ while [ -n "${1}" ]; do
1779
1780 sensors | netdata-sensors)
1781 PACKAGES_NETDATA=1
1764 - PACKAGES_NETDATA_PYTHON=1
1782 + PACKAGES_NETDATA_PYTHON3=1
1783 PACKAGES_NETDATA_SENSORS=1
1784 PACKAGES_NETDATA_DATABASE=1
1785 ;;
@@ -1777,11 +1795,17 @@ while [ -n "${1}" ]; do
1795 demo | all)
1796 PACKAGES_NETDATA=1
1797 PACKAGES_NETDATA_NODEJS=1
1780 - PACKAGES_NETDATA_PYTHON=1
1781 - PACKAGES_NETDATA_PYTHON3=1
1782 - PACKAGES_NETDATA_PYTHON_MYSQL=1
1783 - PACKAGES_NETDATA_PYTHON_POSTGRES=1
1784 - PACKAGES_NETDATA_PYTHON_MONGO=1
1798 + if [ "${pv}" -eq 2 ] ; then
1799 + PACKAGES_NETDATA_PYTHON=1
1800 + PACKAGES_NETDATA_PYTHON_MYSQL=1
1801 + PACKAGES_NETDATA_PYTHON_POSTGRES=1
1802 + PACKAGES_NETDATA_PYTHON_MONGO=1
1803 + else
1804 + PACKAGES_NETDATA_PYTHON3=1
1805 + PACKAGES_NETDATA_PYTHON3_MYSQL=1
1806 + PACKAGES_NETDATA_PYTHON3_POSTGRES=1
1807 + PACKAGES_NETDATA_PYTHON3_MONGO=1
1808 + fi
1809 PACKAGES_DEBUG=1
1810 PACKAGES_IPRANGE=1
1811 PACKAGES_FIREHOL=1
@@ -1830,19 +1854,6 @@ if [ -z "${package_installer}" ] || [ -z "${tree}" ]; then
1854 validate_package_trees
1855 fi
1856
1833 -pv=$(python --version 2>&1)
1834 -if [[ "${pv}" =~ ^Python\ 2.* ]]; then
1835 - pv=2
1836 -elif [[ "${pv}" =~ ^Python\ 3.* ]]; then
1837 - pv=3
1838 - PACKAGES_NETDATA_PYTHON3=1
1839 -elif [[ "${tree}" == "centos" ]] && [ "${version}" -lt 8 ]; then
1840 - pv=2
1841 -else
1842 - pv=3
1843 - PACKAGES_NETDATA_PYTHON3=1
1844 -fi
1845 -
1857 [ "${detection}" = "/etc/os-release" ] && cat << EOF
1858
1859 /etc/os-release information:
packaging/makeself/makeself-header.sh
+3 -4
@@ -1,4 +1,6 @@
1 # SPDX-License-Identifier: GPL-3.0-or-later
2 +# shellcheck shell=sh
3 +# shellcheck disable=SC2154,SC2039
4 cat << EOF > "$archname"
5 #!/bin/sh
6 # This script was generated using Makeself $MS_VERSION
@@ -288,7 +290,7 @@ do
290 echo CRCsum=\"\$CRCsum\"
291 echo MD5sum=\"\$MD5\"
292 echo OLDUSIZE=$USIZE
291 - echo OLDSKIP=`expr $SKIP + 1`
293 + echo OLDSKIP=$((SKIP + 1))
294 exit 0
295 ;;
296 --lsm)
@@ -438,9 +440,6 @@ if test x"\$nox11" = xn; then
440 fi
441 fi
442
441 -[ -d "\$targetdir/etc/netdata.old" ] && echo "Moving existing old directory" && mv "\$targetdir/etc/netdata.old" "\$targetdir/etc/netdata.old.$$"
442 -[ -d \$targetdir/etc/netdata ] && echo "Backing up existing directory" && cp -r \$targetdir/etc/netdata "\$targetdir/etc/netdata.old"
443 -
443 if test x"\$targetdir" = x.; then
444 tmpdir="."
445 else