arch.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/env bash
  2. # Package tree used for installing netdata on distribution:
  3. # << ArchLinux: [base] [base-devel] >> | << Manjaro >>
  4. set -e
  5. NON_INTERACTIVE=0
  6. DONT_WAIT=0
  7. declare -a package_tree=(
  8. gcc
  9. make
  10. autoconf
  11. autoconf-archive
  12. autogen
  13. automake
  14. libtool
  15. cmake
  16. gnu-netcat
  17. zlib
  18. util-linux
  19. libmnl
  20. json-c
  21. libuv
  22. lz4
  23. openssl
  24. libelf
  25. git
  26. pkgconfig
  27. tar
  28. curl
  29. gzip
  30. python3
  31. binutils
  32. )
  33. usage() {
  34. cat << EOF
  35. OPTIONS:
  36. [--dont-wait] [--non-interactive] [ ]
  37. EOF
  38. }
  39. check_flags() {
  40. while [ -n "${1}" ]; do
  41. case "${1}" in
  42. dont-wait | --dont-wait | -n)
  43. DONT_WAIT=1
  44. ;;
  45. non-interactive | --non-interactive | -y)
  46. NON_INTERACTIVE=1
  47. ;;
  48. help | -h | --help)
  49. usage
  50. exit 1
  51. ;;
  52. *)
  53. echo >&2 "ERROR: Cannot understand option '${1}'"
  54. echo >&2
  55. usage
  56. exit 1
  57. ;;
  58. esac
  59. shift
  60. done
  61. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  62. read -r -p "Press ENTER to run it > " || exit 1
  63. fi
  64. }
  65. # shellcheck disable=SC2068
  66. check_flags ${@}
  67. packages_to_install=
  68. # shellcheck disable=SC2068
  69. for package in ${package_tree[@]}; do
  70. if pacman -Qn "$package" &> /dev/null; then
  71. echo "Package '${package}' is installed"
  72. else
  73. echo "Package '$package' is NOT installed"
  74. packages_to_install="$packages_to_install $package"
  75. fi
  76. done
  77. if [[ -z $packages_to_install ]]; then
  78. echo "All required packages are already installed. Skipping .."
  79. else
  80. echo "packages_to_install: " "${packages_to_install[@]}"
  81. opts=
  82. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  83. echo >&2 "Running in non-interactive mode"
  84. opts="--noconfirm"
  85. fi
  86. # shellcheck disable=SC2068
  87. pacman -Sy ${opts} ${packages_to_install[@]}
  88. fi