fedora.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. if [[ $(os_version) -gt 24 ]]; then
  17. ulogd_pkg=
  18. else
  19. ulogd_pkg=ulogd
  20. fi
  21. declare -a package_tree=(
  22. autoconf
  23. autoconf-archive
  24. autogen
  25. automake
  26. bison
  27. cmake
  28. curl
  29. elfutils-libelf-devel
  30. findutils
  31. flex
  32. gcc
  33. gcc-c++
  34. git
  35. gzip
  36. json-c-devel
  37. libatomic
  38. libmnl-devel
  39. libtool
  40. libuuid-devel
  41. libuv-devel
  42. libyaml-devel
  43. lz4-devel
  44. make
  45. openssl-devel
  46. pkgconfig
  47. python3
  48. systemd-devel
  49. tar
  50. zlib-devel
  51. "${ulogd_pkg}"
  52. )
  53. usage() {
  54. cat << EOF
  55. OPTIONS:
  56. [--dont-wait] [--non-interactive] [ ]
  57. EOF
  58. }
  59. check_flags() {
  60. while [ -n "${1}" ]; do
  61. case "${1}" in
  62. dont-wait | --dont-wait | -n)
  63. DONT_WAIT=1
  64. ;;
  65. non-interactive | --non-interactive | -y)
  66. NON_INTERACTIVE=1
  67. ;;
  68. help | -h | --help)
  69. usage
  70. exit 1
  71. ;;
  72. *)
  73. echo >&2 "ERROR: Cannot understand option '${1}'"
  74. echo >&2
  75. usage
  76. exit 1
  77. ;;
  78. esac
  79. shift
  80. done
  81. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  82. read -r -p "Press ENTER to run it > " || exit 1
  83. fi
  84. }
  85. # shellcheck disable=SC2068
  86. check_flags ${@}
  87. packages_to_install=
  88. # shellcheck disable=SC2068
  89. for package in ${package_tree[@]}; do
  90. if rpm -q "$package" &> /dev/null; then
  91. echo "Package '${package}' is installed"
  92. else
  93. echo "Package '$package' is NOT installed"
  94. packages_to_install="$packages_to_install $package"
  95. fi
  96. done
  97. if [[ -z $packages_to_install ]]; then
  98. echo "All required packages are already installed. Skipping .."
  99. else
  100. echo "packages_to_install:" "${packages_to_install[@]}"
  101. opts=
  102. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  103. echo >&2 "Running in non-interactive mode"
  104. opts="-y"
  105. fi
  106. # shellcheck disable=SC2068
  107. dnf install ${opts} ${packages_to_install[@]}
  108. fi