ubuntu.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/usr/bin/env bash
  2. # Package tree used for installing netdata on distribution:
  3. # << Ubuntu: [18.04] [20.04] [20.10] [21.04] [21.10] >> | << Linux Mint >>
  4. set -e
  5. NON_INTERACTIVE=0
  6. DONT_WAIT=0
  7. package_tree="
  8. autoconf
  9. autoconf-archive
  10. autogen
  11. automake
  12. bison
  13. cmake
  14. curl
  15. flex
  16. g++
  17. gcc
  18. git
  19. gzip
  20. libatomic1
  21. libelf-dev
  22. libjson-c-dev
  23. liblz4-dev
  24. libmnl-dev
  25. libssl-dev
  26. libsystemd-dev
  27. libtool
  28. libuv1-dev
  29. libyaml-dev
  30. make
  31. pkg-config
  32. python3
  33. tar
  34. uuid-dev
  35. zlib1g-dev
  36. "
  37. usage() {
  38. cat << EOF
  39. OPTIONS:
  40. [--dont-wait] [--non-interactive] [ ]
  41. EOF
  42. }
  43. check_flags() {
  44. while [ -n "${1}" ]; do
  45. case "${1}" in
  46. dont-wait | --dont-wait | -n)
  47. DONT_WAIT=1
  48. ;;
  49. non-interactive | --non-interactive | -y)
  50. NON_INTERACTIVE=1
  51. ;;
  52. help | -h | --help)
  53. usage
  54. exit 1
  55. ;;
  56. *)
  57. echo >&2 "ERROR: Cannot understand option '${1}'"
  58. echo >&2
  59. usage
  60. exit 1
  61. ;;
  62. esac
  63. shift
  64. done
  65. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  66. read -r -p "Press ENTER to run it > " || exit 1
  67. fi
  68. }
  69. # shellcheck disable=SC2068
  70. check_flags ${@}
  71. packages_to_install=
  72. for package in $package_tree; do
  73. if dpkg -s "$package" &> /dev/null; then
  74. echo "Package '${package}' is installed"
  75. else
  76. echo "Package '${package}' is NOT installed"
  77. packages_to_install="$packages_to_install $package"
  78. fi
  79. done
  80. if [[ -z "$packages_to_install" ]]; then
  81. echo "All required packages are already installed. Skipping .."
  82. else
  83. echo "packages_to_install:" "$packages_to_install"
  84. opts=
  85. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  86. echo >&2 "Running in non-interactive mode"
  87. export DEBIAN_FRONTEND="noninteractive"
  88. opts="${opts} -yq"
  89. fi
  90. echo "Running apt-get update and updating your APT caches ..."
  91. apt-get update
  92. # shellcheck disable=SC2086
  93. apt-get install ${opts} $packages_to_install
  94. fi