sha256.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #! /bin/sh
  2. # Copyright (C) 2019 ng0 <ng0@n0.is>
  3. # Copyright (C) 2019 Jeremiah Orians
  4. #
  5. # This file is part of mescc-tools
  6. #
  7. # mescc-tools is free software; you can redistribute it and/or modify it
  8. # under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or (at
  10. # your option) any later version.
  11. #
  12. # mescc-tools is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with mescc-tools. If not, see <http://www.gnu.org/licenses/>.
  19. set -ex
  20. # It's bad to rely on the uname here, but it's a start.
  21. # What this does is to consider the major implementations of
  22. # sha256sum tools and their differences and call them
  23. # accordingly.
  24. sha256_check()
  25. {
  26. if [ "$(./bin/get_machine --OS)" = "Linux" ]; then
  27. LANG=C sha256sum -c "$1"
  28. elif [ "$(./bin/get_machine --OS)" = "NetBSD" ]; then
  29. sum -a SHA256 -n -c "$1"
  30. elif [ "$(./bin/get_machine --OS)" = "FreeBSD" ]; then
  31. sha256 -r -c "$1"
  32. else
  33. echo "Unsupported sha256 tool, please send a patch to support it"
  34. exit 77
  35. fi
  36. }