pkg-test.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/sh
  2. SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
  3. install_debian_like() {
  4. # This is needed to ensure package installs don't prompt for any user input.
  5. export DEBIAN_FRONTEND=noninteractive
  6. if apt-cache show netcat 2>&1 | grep -q "No packages found"; then
  7. netcat="netcat-traditional"
  8. else
  9. netcat="netcat"
  10. fi
  11. apt-get update
  12. # Install Netdata
  13. # Strange quoting is required here so that glob matching works.
  14. # shellcheck disable=SC2046
  15. apt-get install -y $(find /netdata/artifacts -type f -name 'netdata*.deb' \
  16. ! -name '*dbgsym*' ! -name '*cups*' ! -name '*freeipmi*') || exit 3
  17. # Install testing tools
  18. apt-get install -y --no-install-recommends curl "${netcat}" jq || exit 1
  19. }
  20. install_fedora_like() {
  21. # Using a glob pattern here because I can't reliably determine what the
  22. # resulting package name will be (TODO: There must be a better way!)
  23. PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")"
  24. if [ "${PKGMGR}" = "dnf" ]; then
  25. opts="--allowerasing"
  26. fi
  27. # Install Netdata
  28. # Strange quoting is required here so that glob matching works.
  29. "${PKGMGR}" install -y /netdata/artifacts/netdata*.rpm || exit 1
  30. # Install testing tools
  31. "${PKGMGR}" install -y curl nc jq || exit 1
  32. }
  33. install_centos() {
  34. # Using a glob pattern here because I can't reliably determine what the
  35. # resulting package name will be (TODO: There must be a better way!)
  36. PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")"
  37. if [ "${PKGMGR}" = "dnf" ]; then
  38. opts="--allowerasing"
  39. fi
  40. # Install EPEL (needed for `jq`
  41. "${PKGMGR}" install -y epel-release || exit 1
  42. # Install Netdata
  43. # Strange quoting is required here so that glob matching works.
  44. "${PKGMGR}" install -y /netdata/artifacts/netdata*.rpm || exit 1
  45. # Install testing tools
  46. # shellcheck disable=SC2086
  47. "${PKGMGR}" install -y ${opts} curl nc jq || exit 1
  48. }
  49. install_amazon_linux() {
  50. PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")"
  51. if [ "${PKGMGR}" = "dnf" ]; then
  52. opts="--allowerasing"
  53. fi
  54. # Install Netdata
  55. # Strange quoting is required here so that glob matching works.
  56. "${PKGMGR}" install -y /netdata/artifacts/netdata*.rpm || exit 1
  57. # Install testing tools
  58. # shellcheck disable=SC2086
  59. "${PKGMGR}" install -y ${opts} curl nc jq || exit 1
  60. }
  61. install_suse_like() {
  62. # Using a glob pattern here because I can't reliably determine what the
  63. # resulting package name will be (TODO: There must be a better way!)
  64. # Install Netdata
  65. # Strange quoting is required here so that glob matching works.
  66. zypper install -y --allow-downgrade --allow-unsigned-rpm /netdata/artifacts/netdata*.rpm || exit 1
  67. # Install testing tools
  68. zypper install -y --allow-downgrade --no-recommends curl netcat-openbsd jq || exit 1
  69. }
  70. dump_log() {
  71. cat ./netdata.log
  72. }
  73. case "${DISTRO}" in
  74. debian | ubuntu)
  75. install_debian_like
  76. ;;
  77. fedora | oraclelinux)
  78. install_fedora_like
  79. ;;
  80. centos| centos-stream | rockylinux | almalinux)
  81. install_centos
  82. ;;
  83. amazonlinux)
  84. install_amazon_linux
  85. ;;
  86. opensuse)
  87. install_suse_like
  88. ;;
  89. *)
  90. printf "ERROR: unsupported distro: %s_%s\n" "${DISTRO}" "${DISTRO_VERSION}"
  91. exit 1
  92. ;;
  93. esac
  94. trap dump_log EXIT
  95. /usr/sbin/netdata -D > ./netdata.log 2>&1 &
  96. "${SCRIPT_DIR}/../../packaging/runtime-check.sh" || exit 1
  97. trap - EXIT