opensuse.sh 1.9 KB

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