clearlinux.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env bash
  2. # Package tree used for installing netdata on distribution:
  3. # << ClearLinux: [base] >>
  4. set -e
  5. NON_INTERACTIVE=0
  6. DONT_WAIT=0
  7. declare -a package_tree=(
  8. c-basic
  9. make
  10. sysadmin-basic
  11. devpkg-zlib
  12. devpkg-util-linux
  13. devpkg-libmnl
  14. devpkg-json-c
  15. devpkg-libuv
  16. devpkg-lz4
  17. devpkg-openssl
  18. devpkg-elfutils
  19. git
  20. findutils
  21. curl
  22. gzip
  23. python3-basic
  24. )
  25. usage() {
  26. cat << EOF
  27. OPTIONS:
  28. [--dont-wait] [--non-interactive] [ ]
  29. EOF
  30. }
  31. check_flags() {
  32. while [ -n "${1}" ]; do
  33. case "${1}" in
  34. dont-wait | --dont-wait | -n)
  35. DONT_WAIT=1
  36. ;;
  37. non-interactive | --non-interactive | -y)
  38. NON_INTERACTIVE=1
  39. ;;
  40. help | -h | --help)
  41. usage
  42. exit 1
  43. ;;
  44. *)
  45. echo >&2 "ERROR: Cannot understand option '${1}'"
  46. echo >&2
  47. usage
  48. exit 1
  49. ;;
  50. esac
  51. shift
  52. done
  53. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  54. read -r -p "Press ENTER to run it > " || exit 1
  55. fi
  56. }
  57. # shellcheck disable=SC2068
  58. check_flags ${@}
  59. packages_to_install=
  60. # shellcheck disable=SC2068
  61. for package in ${package_tree[@]}; do
  62. if [[ "$(swupd bundle-info "$package" | grep Status | cut -d':' -f2)" == " Not installed" ]]; then
  63. echo "Package '$package' is NOT installed"
  64. packages_to_install="$packages_to_install $package"
  65. else
  66. echo "Package '$package' is installed"
  67. fi
  68. done
  69. if [[ -z $packages_to_install ]]; then
  70. echo "All required packages are already installed. Skipping .."
  71. else
  72. echo "packages_to_install: " "${packages_to_install[@]}"
  73. # shellcheck disable=SC2068
  74. swupd bundle-add ${packages_to_install[@]}
  75. fi