opensuse.sh 2.0 KB

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