2006-11-25 01:08:38 -01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2010-07-05 14:09:23 +00:00
|
|
|
VERBOSE=0
|
|
|
|
|
|
|
|
if [ "$1" = "-v" ] ; then
|
|
|
|
VERBOSE=1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2006-11-25 01:08:38 -01:00
|
|
|
cd $1
|
|
|
|
|
2008-12-17 22:34:11 -01:00
|
|
|
if [ "$2"x != ""x ] ; then
|
2008-12-26 00:08:44 -01:00
|
|
|
EXT="$2"
|
2008-12-17 22:34:11 -01:00
|
|
|
fi
|
|
|
|
|
2010-05-27 00:52:25 +00:00
|
|
|
if [ "$CHECKSUMS"x = ""x ] ; then
|
2019-07-16 15:22:42 +00:00
|
|
|
CHECKSUMS="sha512 sha256"
|
2010-05-27 00:52:25 +00:00
|
|
|
fi
|
2009-05-10 23:12:52 +00:00
|
|
|
|
|
|
|
for SUM in $CHECKSUMS; do
|
2018-02-15 15:18:21 -01:00
|
|
|
UPSUM=$(echo $SUM | tr 'a-z' 'A-Z')
|
|
|
|
FILE=$UPSUM"SUMS"$EXT
|
|
|
|
if [ $VERBOSE -eq 1 ] ; then
|
|
|
|
echo "Clearing $PWD/$FILE"
|
|
|
|
fi
|
|
|
|
:> $FILE
|
2009-05-10 23:12:52 +00:00
|
|
|
done
|
2006-11-25 01:08:38 -01:00
|
|
|
|
2018-02-15 15:17:57 -01:00
|
|
|
# Ordering is important in the "find" call here - we *really* want to
|
|
|
|
# get the jigdo files before the iso files, so we can use the
|
|
|
|
# checksums there first instead of re-calculating them
|
|
|
|
for file in $(find * \
|
|
|
|
-name '*.jigdo' -o -name '*.template' \
|
|
|
|
-o -name '*.iso' -o -name '*.torrent'); do
|
2018-02-11 20:13:56 -01:00
|
|
|
iso=""
|
2008-09-10 22:16:18 +00:00
|
|
|
case $file in
|
|
|
|
*.jigdo)
|
2008-04-20 14:33:19 +00:00
|
|
|
iso=${file%%.jigdo}.iso
|
2008-09-10 22:16:18 +00:00
|
|
|
JIGDO=1
|
|
|
|
;;
|
|
|
|
*.iso)
|
|
|
|
iso=$file
|
|
|
|
JIGDO=0
|
|
|
|
;;
|
2018-02-15 15:17:57 -01:00
|
|
|
*.template|*.torrent)
|
|
|
|
;;
|
2008-09-10 22:16:18 +00:00
|
|
|
*)
|
|
|
|
echo "Found unexpected file $file!"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2008-04-20 14:33:19 +00:00
|
|
|
|
2018-02-15 15:18:21 -01:00
|
|
|
for SUM in $CHECKSUMS; do
|
|
|
|
UPSUM=$(echo $SUM | tr 'a-z' 'A-Z')
|
|
|
|
FILE=$UPSUM"SUMS"$EXT
|
|
|
|
CMD="$SUM"sum
|
2009-05-10 23:12:52 +00:00
|
|
|
|
2018-02-15 15:18:21 -01:00
|
|
|
if [ "$iso"x != ""x ]; then
|
|
|
|
grep -q $iso $FILE
|
|
|
|
if [ $? -ne 0 ] ; then
|
|
|
|
CKSUM=""
|
|
|
|
if [ "$JIGDO" == 1 ] ; then
|
|
|
|
CKSUM=$(zcat -f $file | \
|
|
|
|
grep -i "Image Hex $CMD" | \
|
|
|
|
awk '{print $5}')
|
|
|
|
fi
|
|
|
|
if [ "$CKSUM"x != ""x ] ; then
|
|
|
|
echo "$CKSUM $iso" >> $FILE
|
|
|
|
grep $iso $FILE
|
|
|
|
else
|
|
|
|
echo "No Jigdo help for $SUM, doing it the long way with $CMD"
|
|
|
|
$CMD $iso >> $FILE
|
|
|
|
grep $iso $FILE
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2008-09-10 22:16:18 +00:00
|
|
|
|
2018-02-15 15:17:57 -01:00
|
|
|
# Also add the template, jigdo and torrent files to the SUMS,
|
|
|
|
# if they exist
|
|
|
|
case $file in
|
|
|
|
*.template|*.jigdo|*.torrent)
|
|
|
|
$CMD $file >> $FILE
|
|
|
|
grep $file $FILE
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2008-09-10 22:16:18 +00:00
|
|
|
done
|