opensuse.sh 1.9 KB

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