checksums.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. #
  3. # Mechanism to validate kickstart files integrity status
  4. #
  5. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  6. #
  7. # Author : Pawel Krupa (pawel@netdata.cloud)
  8. # Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud)
  9. # Author : Austin S. Hemmelgarn (austin@netdata.cloud)
  10. set -e
  11. # If we are not in netdata git repo, at the top level directory, fail
  12. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || echo "")")
  13. CWD="$(git rev-parse --show-cdup 2>/dev/null || echo "")"
  14. if [ -n "$CWD" ] || [ "${TOP_LEVEL}" != "netdata" ]; then
  15. echo "Run as ./tests/installer/$(basename "$0") from top level directory of netdata git repository"
  16. echo "Kickstart validation process aborted"
  17. exit 1
  18. fi
  19. check_file() {
  20. README_MD5=$(grep "$1" "$2" | grep md5sum | grep curl | cut -d '"' -f2)
  21. KICKSTART_URL="https://my-netdata.io/$1"
  22. KICKSTART="packaging/installer/$1"
  23. KICKSTART_MD5="$(md5sum "${KICKSTART}" | cut -d' ' -f1)"
  24. CALCULATED_MD5="$(curl -Ss "${KICKSTART_URL}" | md5sum | cut -d ' ' -f 1)"
  25. # Conditionally run the website validation
  26. if [ -z "${LOCAL_ONLY}" ]; then
  27. echo "Validating ${KICKSTART_URL} against local file ${KICKSTART} with MD5 ${KICKSTART_MD5}.."
  28. if [ "$KICKSTART_MD5" = "$CALCULATED_MD5" ]; then
  29. echo "${KICKSTART_URL} looks fine"
  30. else
  31. echo "${KICKSTART_URL} md5sum does not match local file, it needs to be updated"
  32. exit 2
  33. fi
  34. fi
  35. echo "Validating documentation for $1"
  36. if [ "$KICKSTART_MD5" != "$README_MD5" ]; then
  37. echo "Invalid checksum for $1 in $2."
  38. echo "checksum in docs: $README_MD5"
  39. echo "current checksum: $KICKSTART_MD5"
  40. exit 2
  41. else
  42. echo "$1 MD5Sum is well documented"
  43. fi
  44. }
  45. check_file kickstart.sh packaging/installer/methods/kickstart.md
  46. echo "No problems found, exiting successfully!"