updater_checks.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/env sh
  2. #
  3. # Wrapper script that installs the required dependencies
  4. # for the BATS script to run successfully
  5. #
  6. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  7. #
  8. # Author : Pavlos Emm. Katsoulakis <paul@netdata.cloud)
  9. #
  10. echo "Syncing/updating repository.."
  11. blind_arch_grep_install() {
  12. # There is a peculiar docker case with arch, where grep is not available
  13. # This method will have to be triggered blindly, to inject grep so that we can process
  14. # It starts to become a chicken-egg situation with all the distros..
  15. echo "* * Workaround hack * *"
  16. echo "Attempting blind install for archlinux case"
  17. if command -v pacman > /dev/null 2>&1; then
  18. echo "Executing grep installation"
  19. pacman -Sy
  20. pacman --noconfirm --needed -S grep
  21. fi
  22. }
  23. blind_arch_grep_install || echo "Workaround failed, proceed as usual"
  24. running_os="$(grep '^ID=' /etc/os-release | cut -d'=' -f2 | sed -e 's/"//g')"
  25. case "${running_os}" in
  26. "centos"|"fedora"|"CentOS")
  27. echo "Running on CentOS, updating YUM repository.."
  28. yum clean all
  29. yum update -y
  30. echo "Installing extra dependencies.."
  31. yum install -y epel-release
  32. yum install -y bats curl
  33. ;;
  34. "debian"|"ubuntu")
  35. echo "Running ${running_os}, updating APT repository"
  36. apt-get update -y
  37. apt-get install -y bats curl
  38. ;;
  39. "opensuse-leap"|"opensuse-tumbleweed")
  40. zypper update -y
  41. zypper install -y bats curl
  42. # Fixes curl: (60) SSL certificate problem: unable to get local issuer certificate
  43. # https://travis-ci.com/netdata/netdata/jobs/267573805
  44. update-ca-certificates
  45. ;;
  46. "arch")
  47. pacman --noconfirm -Syu
  48. pacman --noconfirm --needed -S bash-bats curl libffi
  49. ;;
  50. "alpine")
  51. apk update
  52. apk add bash curl bats
  53. ;;
  54. *)
  55. echo "Running on ${running_os}, no repository preparation done"
  56. ;;
  57. esac
  58. # Run dependency scriptlet, before anything else
  59. #
  60. ./packaging/installer/install-required-packages.sh --non-interactive netdata
  61. echo "Running BATS file.."
  62. bats --tap tests/updater_checks.bats