clearlinux.sh 1.7 KB

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