opensuse.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. cmake
  11. curl
  12. gcc
  13. gcc-c++
  14. git
  15. gzip
  16. libatomic1
  17. libelf-devel
  18. libjson-c-devel
  19. liblz4-devel
  20. libmnl-devel
  21. libopenssl-devel
  22. libuuid-devel
  23. libuv-devel
  24. libyaml-devel
  25. make
  26. pkg-config
  27. python3
  28. systemd-devel
  29. tar
  30. zlib-devel
  31. )
  32. usage() {
  33. cat << EOF
  34. OPTIONS:
  35. [--dont-wait] [--non-interactive] [ ]
  36. EOF
  37. }
  38. check_flags() {
  39. while [ -n "${1}" ]; do
  40. case "${1}" in
  41. dont-wait | --dont-wait | -n)
  42. DONT_WAIT=1
  43. ;;
  44. non-interactive | --non-interactive | -y)
  45. NON_INTERACTIVE=1
  46. ;;
  47. help | -h | --help)
  48. usage
  49. exit 1
  50. ;;
  51. *)
  52. echo >&2 "ERROR: Cannot understand option '${1}'"
  53. echo >&2
  54. usage
  55. exit 1
  56. ;;
  57. esac
  58. shift
  59. done
  60. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  61. read -r -p "Press ENTER to run it > " || exit 1
  62. fi
  63. }
  64. # shellcheck disable=SC2068
  65. check_flags ${@}
  66. packages_to_install=
  67. # shellcheck disable=SC2068
  68. for package in ${package_tree[@]}; do
  69. if zypper search -i "$package" &> /dev/null; then
  70. echo "Package '${package}' is installed"
  71. else
  72. echo "Package '$package' is NOT installed"
  73. packages_to_install="$packages_to_install $package"
  74. fi
  75. done
  76. if [[ -z $packages_to_install ]]; then
  77. echo "All required packages are already installed. Skipping .."
  78. else
  79. echo "packages_to_install:" "${packages_to_install[@]}"
  80. opts="--ignore-unknown"
  81. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  82. echo >&2 "Running in non-interactive mode"
  83. opts="--non-interactive"
  84. fi
  85. # shellcheck disable=SC2068
  86. zypper ${opts} install ${packages_to_install[@]}
  87. fi