diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-12-28 20:08:30 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-12-28 20:08:30 +0800 |
commit | 51344fd4ffce9298b976255890edec6f214845a4 (patch) | |
tree | 5db4c441def40b8e2179781353b2402e42fdcf5b /functions.sh | |
parent | d44f8aa5b0241150be607de76b5c612cf61ac767 (diff) | |
download | liveusb-builder-51344fd4ffce9298b976255890edec6f214845a4.tar.xz |
a common hashfile verify function
Diffstat (limited to 'functions.sh')
-rw-r--r-- | functions.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/functions.sh b/functions.sh index 488141f..45c6ac6 100644 --- a/functions.sh +++ b/functions.sh @@ -25,6 +25,20 @@ checksum_verify() { fi } +# a hash verify function that uses a checksum file +# usage: set HASHTOOL and HASHFILE in isoinfo, set VERIFY as hashfile +hashfile() { + local _cksum _hashsum + _cksum=$("$HASHTOOL" "$ISOPATH/$ISOFILE" | cut -d' ' -f1) + _hashsum=$(grep "${ISOFILE}\$" "$HASHFILE" | cut -d' ' -f1) + + if [[ $_cksum == $_hashsum ]]; then + msg "$ISOFILE ok." + else + msg "$ISOFILE checksum bad!" && return 1 + fi +} + set_distro() { _distrobase="distro/$(cut -d'/' -f1 <<< "$1")" source "$_distrobase/distroinfo" |