clearlinux.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. yaml-dev
  16. devpkg-libuv
  17. devpkg-lz4
  18. devpkg-openssl
  19. devpkg-elfutils
  20. git
  21. findutils
  22. curl
  23. gzip
  24. python3-basic
  25. )
  26. usage() {
  27. cat << EOF
  28. OPTIONS:
  29. [--dont-wait] [--non-interactive] [ ]
  30. EOF
  31. }
  32. check_flags() {
  33. while [ -n "${1}" ]; do
  34. case "${1}" in
  35. dont-wait | --dont-wait | -n)
  36. DONT_WAIT=1
  37. ;;
  38. non-interactive | --non-interactive | -y)
  39. NON_INTERACTIVE=1
  40. ;;
  41. help | -h | --help)
  42. usage
  43. exit 1
  44. ;;
  45. *)
  46. echo >&2 "ERROR: Cannot understand option '${1}'"
  47. echo >&2
  48. usage
  49. exit 1
  50. ;;
  51. esac
  52. shift
  53. done
  54. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  55. read -r -p "Press ENTER to run it > " || exit 1
  56. fi
  57. }
  58. # shellcheck disable=SC2068
  59. check_flags ${@}
  60. packages_to_install=
  61. # shellcheck disable=SC2068
  62. for package in ${package_tree[@]}; do
  63. if [[ "$(swupd bundle-info "$package" | grep Status | cut -d':' -f2)" == " Not installed" ]]; then
  64. echo "Package '$package' is NOT installed"
  65. packages_to_install="$packages_to_install $package"
  66. else
  67. echo "Package '$package' is installed"
  68. fi
  69. done
  70. if [[ -z $packages_to_install ]]; then
  71. echo "All required packages are already installed. Skipping .."
  72. else
  73. echo "packages_to_install: " "${packages_to_install[@]}"
  74. # shellcheck disable=SC2068
  75. swupd bundle-add ${packages_to_install[@]}
  76. fi