opensuse.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env bash
  2. # Package tree used for installing netdata on distribution:
  3. # << opeSUSE >>
  4. # supported versions: leap/15.3 and tumbleweed
  5. # it may work with SLES as well, although we have not tested with it
  6. set -e
  7. NON_INTERACTIVE=0
  8. DONT_WAIT=0
  9. declare -a package_tree=(
  10. gcc
  11. gcc-c++
  12. make
  13. autoconf
  14. autoconf-archive
  15. autogen
  16. automake
  17. libatomic1
  18. libtool
  19. pkg-config
  20. cmake
  21. zlib-devel
  22. libuuid-devel
  23. libmnl-devel
  24. libjson-c-devel
  25. libyaml-devel
  26. libuv-devel
  27. liblz4-devel
  28. libopenssl-devel
  29. libelf-devel
  30. git
  31. tar
  32. curl
  33. gzip
  34. python3
  35. )
  36. usage() {
  37. cat << EOF
  38. OPTIONS:
  39. [--dont-wait] [--non-interactive] [ ]
  40. EOF
  41. }
  42. check_flags() {
  43. while [ -n "${1}" ]; do
  44. case "${1}" in
  45. dont-wait | --dont-wait | -n)
  46. DONT_WAIT=1
  47. ;;
  48. non-interactive | --non-interactive | -y)
  49. NON_INTERACTIVE=1
  50. ;;
  51. help | -h | --help)
  52. usage
  53. exit 1
  54. ;;
  55. *)
  56. echo >&2 "ERROR: Cannot understand option '${1}'"
  57. echo >&2
  58. usage
  59. exit 1
  60. ;;
  61. esac
  62. shift
  63. done
  64. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  65. read -r -p "Press ENTER to run it > " || exit 1
  66. fi
  67. }
  68. # shellcheck disable=SC2068
  69. check_flags ${@}
  70. packages_to_install=
  71. # shellcheck disable=SC2068
  72. for package in ${package_tree[@]}; do
  73. if zypper search -i "$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="--ignore-unknown"
  85. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  86. echo >&2 "Running in non-interactive mode"
  87. opts="--non-interactive"
  88. fi
  89. # shellcheck disable=SC2068
  90. zypper ${opts} install ${packages_to_install[@]}
  91. fi