alpine.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/sh
  2. # Package tree used for installing netdata on distribution:
  3. # << Alpine: [3.12] [3.13] [3.14] [3.15] [edge] >>
  4. set -e
  5. NON_INTERACTIVE=0
  6. DONT_WAIT=0
  7. package_tree="
  8. alpine-sdk
  9. cmake
  10. coreutils
  11. curl
  12. elfutils-dev
  13. g++
  14. gcc
  15. git
  16. gzip
  17. json-c-dev
  18. libatomic
  19. libmnl-dev
  20. libuv-dev
  21. lz4-dev
  22. make
  23. openssl-dev
  24. pkgconfig
  25. python3
  26. tar
  27. util-linux-dev
  28. yaml-dev
  29. zlib-dev
  30. "
  31. usage() {
  32. cat << EOF
  33. OPTIONS:
  34. [--dont-wait] [--non-interactive] [ ]
  35. EOF
  36. }
  37. check_flags() {
  38. while [ -n "${1}" ]; do
  39. case "${1}" in
  40. dont-wait | --dont-wait | -n)
  41. DONT_WAIT=1
  42. ;;
  43. non-interactive | --non-interactive | -y)
  44. NON_INTERACTIVE=1
  45. ;;
  46. help | -h | --help)
  47. usage
  48. exit 1
  49. ;;
  50. *)
  51. echo >&2 "ERROR: Cannot understand option '${1}'"
  52. echo >&2
  53. usage
  54. exit 1
  55. ;;
  56. esac
  57. shift
  58. done
  59. if [ "${DONT_WAIT}" -eq 0 ] && [ "${NON_INTERACTIVE}" -eq 0 ]; then
  60. printf "Press ENTER to run it > "
  61. read -r || exit 1
  62. fi
  63. }
  64. # shellcheck disable=2068
  65. check_flags ${@}
  66. packages_to_install=
  67. handle_old_alpine() {
  68. version="$(grep VERSION_ID /etc/os-release | cut -f 2 -d '=')"
  69. major="$(echo "${version}" | cut -f 1 -d '.')"
  70. minor="$(echo "${version}" | cut -f 2 -d '.')"
  71. if [ "${major}" -le 3 ] && [ "${minor}" -le 16 ]; then
  72. package_tree="$(echo "${package_tree}" | sed 's/musl-fts-dev/fts-dev/')"
  73. fi
  74. }
  75. for package in $package_tree; do
  76. if apk -e info "$package" > /dev/null 2>&1 ; then
  77. echo "Package '${package}' is installed"
  78. else
  79. echo "Package '${package}' is NOT installed"
  80. packages_to_install="$packages_to_install $package"
  81. fi
  82. done
  83. if [ -z "${packages_to_install}" ]; then
  84. echo "All required packages are already installed. Skipping .."
  85. else
  86. echo "packages_to_install:" "$packages_to_install"
  87. opts="--force-broken-world"
  88. if [ "${NON_INTERACTIVE}" -eq 1 ]; then
  89. echo >&2 "Running in non-interactive mode"
  90. else
  91. opts="${opts} -i"
  92. fi
  93. # shellcheck disable=SC2086
  94. apk add ${opts} $packages_to_install
  95. fi