debian.sh 1.8 KB

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