fedora.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env bash
  2. # Package tree used for installing netdata on distribution:
  3. # << Fedora: [24->38] >>
  4. set -e
  5. NON_INTERACTIVE=0
  6. DONT_WAIT=0
  7. os_version() {
  8. if [[ -f /etc/os-release ]]; then
  9. # shellcheck disable=SC2002
  10. cat /etc/os-release | grep VERSION_ID | cut -d'=' -f2
  11. else
  12. echo "Error: Cannot determine OS version!"
  13. exit 1
  14. fi
  15. }
  16. declare -a package_tree=(
  17. cmake
  18. curl
  19. elfutils-libelf-devel
  20. findutils
  21. gcc
  22. gcc-c++
  23. git
  24. gzip
  25. json-c-devel
  26. libatomic
  27. libmnl-devel
  28. libuuid-devel
  29. libuv-devel
  30. libyaml-devel
  31. lz4-devel
  32. make
  33. openssl-devel
  34. pkgconfig
  35. python3
  36. systemd-devel
  37. tar
  38. zlib-devel
  39. )
  40. usage() {
  41. cat << EOF
  42. OPTIONS:
  43. [--dont-wait] [--non-interactive] [ ]
  44. EOF
  45. }
  46. check_flags() {
  47. while [ -n "${1}" ]; do
  48. case "${1}" in
  49. dont-wait | --dont-wait | -n)
  50. DONT_WAIT=1
  51. ;;
  52. non-interactive | --non-interactive | -y)
  53. NON_INTERACTIVE=1
  54. ;;
  55. help | -h | --help)
  56. usage
  57. exit 1
  58. ;;
  59. *)
  60. echo >&2 "ERROR: Cannot understand option '${1}'"
  61. echo >&2
  62. usage
  63. exit 1
  64. ;;
  65. esac
  66. shift
  67. done
  68. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  69. read -r -p "Press ENTER to run it > " || exit 1
  70. fi
  71. }
  72. # shellcheck disable=SC2068
  73. check_flags ${@}
  74. packages_to_install=
  75. # shellcheck disable=SC2068
  76. for package in ${package_tree[@]}; do
  77. if rpm -q "$package" &> /dev/null; then
  78. echo "Package '${package}' is installed"
  79. else
  80. echo "Package '$package' is NOT installed"
  81. packages_to_install="$packages_to_install $package"
  82. fi
  83. done
  84. if [[ -z $packages_to_install ]]; then
  85. echo "All required packages are already installed. Skipping .."
  86. else
  87. echo "packages_to_install:" "${packages_to_install[@]}"
  88. opts=
  89. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  90. echo >&2 "Running in non-interactive mode"
  91. opts="-y"
  92. fi
  93. # shellcheck disable=SC2068
  94. dnf install ${opts} ${packages_to_install[@]}
  95. fi