arch.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. judy
  25. libelf
  26. git
  27. pkgconfig
  28. tar
  29. curl
  30. gzip
  31. python3
  32. binutils
  33. )
  34. usage() {
  35. cat << EOF
  36. OPTIONS:
  37. [--dont-wait] [--non-interactive] [ ]
  38. EOF
  39. }
  40. check_flags() {
  41. while [ -n "${1}" ]; do
  42. case "${1}" in
  43. dont-wait | --dont-wait | -n)
  44. DONT_WAIT=1
  45. ;;
  46. non-interactive | --non-interactive | -y)
  47. NON_INTERACTIVE=1
  48. ;;
  49. help | -h | --help)
  50. usage
  51. exit 1
  52. ;;
  53. *)
  54. echo >&2 "ERROR: Cannot understand option '${1}'"
  55. echo >&2
  56. usage
  57. exit 1
  58. ;;
  59. esac
  60. shift
  61. done
  62. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  63. read -r -p "Press ENTER to run it > " || exit 1
  64. fi
  65. }
  66. # shellcheck disable=SC2068
  67. check_flags ${@}
  68. packages_to_install=
  69. # shellcheck disable=SC2068
  70. for package in ${package_tree[@]}; do
  71. if pacman -Qn "$package" &> /dev/null; then
  72. echo "Package '${package}' is installed"
  73. else
  74. echo "Package '$package' is NOT installed"
  75. packages_to_install="$packages_to_install $package"
  76. fi
  77. done
  78. if [[ -z $packages_to_install ]]; then
  79. echo "All required packages are already installed. Skipping .."
  80. else
  81. echo "packages_to_install: " "${packages_to_install[@]}"
  82. opts=
  83. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  84. echo >&2 "Running in non-interactive mode"
  85. opts="--noconfirm"
  86. fi
  87. # shellcheck disable=SC2068
  88. pacman -Sy ${opts} ${packages_to_install[@]}
  89. fi