[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Updated check-debian-cd



I made an update to my check-debian-cd script.  Now it knows about every
Debian CD in the r0 and 0a  series, and about the binary i386 slink CDs.
It also emits different return  codes depending on the failure mode, and
can usefully  be used to  check for  a whole series  of iso images  in a
single run.

I  suggest  it to  be  added  to the  pseudo-image  toolkit,  and to  be
mentioned in the FAQ as an easy way of checking a CD after having burned
it.  To check any Debian CD, just do:
  check-debian-cd
it will automatically recognise the CD and check the MD5 hash.

To check a series of images:
  check-debian-cd *.iso

It can also be run in quiet mode from scripts.

Please note that I do not subscribe to either debian-cd or debian-user.

===File /var/mirrors/potato/check-debian-cd=================
#! /bin/bash

## Made September, 2000 by Francesco Potortì <pot@gnu.org>
## current version is 1.3
## This program is released under the GNU public license, whichever version
##
## BUGS:
## Does not work when file names given as arguments contain spaces

isodefault=/dev/cdrom
quiet=
cdversion=2.2.0

while getopts :qv option; do
    case $option in
	q)
	    quiet=yes ;;
	v)
	    echo $cdversion; exit 0 ;;
	*)  
	    cat <<-EOF
		A program for checking Debian CDs and image files.
		It reads /dev/cdrom or the given files and compares their MD5 hash with
		those contained in an internal database of Debian CDs.
		
		usage: $(basename $0) [options] [files...]
		   Options:
		   -q: run quietly, do not print informative messages
		   -v: print last known version of CD images (currently $cdversion)
		EOF
	    exit 10
    esac
done

bs=2048

## List of known Debian cd image disks: length in $bs, md5sum, id string
## the list is complete as of September, 2000, apart from the slink sources
#
#Id- 312412 c2c046ed739d78d56b1c5b34202268d1 'Debian-i386 2.1 Disc 1          '
#Id- 265072 f126f97fb20f3e1dd4868ae1d3309d24 'Debian-i386 2.1 Disc 2          '
#Id- 315877 b0d41dc89753ed4af3927d2446e8c7fe 'Debian 2.2 r0 Src-1             '
#Id- 326892 3e6272d23a5f6a2f3c8ce92841eca119 'Debian 2.2 r0 Src-1_NONUS       '
#Id- 323574 c04d100965361437e0f970d781153274 'Debian 2.2 r0 Src-2             '
#Id- 321204 a8142b47bce78bc9678ba2dcf52984ba 'Debian 2.2 r0 Src-3             '
#Id- 316351 b5951d4325de81eeaa8514ec78ecab9d 'Debian 2.2 0a alpha Bin-1       '
#Id- 322398 c83fe57ba0f4dc615efcaed19dc166cc 'Debian 2.2 0a alpha Bin-1_NONUS '
#Id- 327489 3b24410ea4fb25e455f2855407d9cb0f 'Debian 2.2 0a alpha Bin-2       '
#Id- 258784 fde444ae21f8ea4f18909d4a7a5acd91 'Debian 2.2 0a alpha Bin-3       '
#Id- 304639 9e757c6cd952efb030383fd6dd327a0f 'Debian 2.2 r0 arm Bin-1         '
#Id- 304977 35bc41583a999c43f33021e0ae4c5716 'Debian 2.2 r0 arm Bin-1_NONUS   '
#Id- 317057 fff543d36e1e313944c463a24dfb4307 'Debian 2.2 r0 arm Bin-2         '
#Id- 50704  4a4f07b7c7130c39f74340e05260a2be 'Debian 2.2 r0 arm Bin-3         '
#Id- 321743 c4435b6a6b8dd91ea51bd69bfb8642df 'Debian 2.2 r0 i386 Bin-1        '
#Id- 327271 aa81c0848d199e9317735a1af0a2e4cc 'Debian 2.2 r0 i386 Bin-1_NONUS  '
#Id- 328594 be04cd6d17159d66978ad227b26ed17d 'Debian 2.2 r0 i386 Bin-2        '
#Id- 257243 13a1509ea29e4891004ca1c397b316a6 'Debian 2.2 r0 i386 Bin-3        '
#Id- 322735 83b0c5b40ca5b31db973d2a28bcc50af 'Debian 2.2 r0 m68k Bin-1        '
#Id- 329160 6ccad6848468e7eccb9a8550215cddc9 'Debian 2.2 r0 m68k Bin-1_NONUS  '
#Id- 330903 a73b2ea406e0c493361236ebffb5ebdb 'Debian 2.2 r0 m68k Bin-2        '
#Id- 111328 5a8c7778d4e18ddd622df8c8f5d4f3e9 'Debian 2.2 r0 m68k Bin-3        '
#Id- 319500 c4435b6a6b8dd91ea51bd69bfb8642df 'Debian 2.2 r0 ppc Bin-1         '
#Id- 324505 aa81c0848d199e9317735a1af0a2e4cc 'Debian 2.2 r0 ppc Bin-1_NONUS   '
#Id- 329991 be04cd6d17159d66978ad227b26ed17d 'Debian 2.2 r0 ppc Bin-2         '
#Id- 141048 13a1509ea29e4891004ca1c397b316a6 'Debian 2.2 r0 ppc Bin-3         '
#Id- 326020 b8eca28f7eb4c96ce7a6f74efbe2f9bf 'Debian 2.2 0a sparc Bin-1       '
#Id- 331717 e5065a6bd3bdaf44bd2f00951c119fb3 'Debian 2.2 0a sparc Bin-1_NONUS '
#Id- 326370 acce0bffbd85edf52f9a446da3c2cb56 'Debian 2.2 0a sparc Bin-2       '
#Id- 153459 25e78e58aac0f229a6d7d60bdc9849ae 'Debian 2.2 0a sparc Bin-3       '

shift $((OPTIND-1))
case $# in
    0)					# no arguments
	iso=$isodefault ;;
    1)					# the image file or device
	iso="$1" ;;
    *)					# more than one file: recursive call
	options=
	test $quiet && options="$options -q"
	exitcode=0
	for arg; do
	    "$0" $options "$arg"
	    ec=$?
	    test $ec -gt $exitcode && exitcode=$ec && test $quiet && break
	done
	exit $exitcode
esac

if [ ! -r "$iso" ]; then
    echo "Cannot read file $iso" >&2
    exit 1
fi

set - $(grep "^#Id-.*'$(dd if=$iso bs=1 skip=32808 count=32 2>/dev/null)'" "$0")
comment=$1
len=$2
sum=$3
shift 3
id="$*"					# disk Id string
id="${id//\'}"				# remove simple quotes
id="${id//% }"				# remove trailing blank
if [ "$comment" = "#Id-" ]; then
    test $quiet || echo "This is \"$id\""
else
    test $quiet || echo "I do not have this disc in my database"
    exit 2
fi

if ! type -t md5sum >/dev/null; then
    echo "Cannot find the md5sum program; exiting" >&2
    exit 11
fi

test $quiet || echo -n "Checking MD5 hash..."
if [ "$(dd if=$iso bs=$bs count=$len 2>/dev/null | md5sum)" = $sum ]; then
    test $quiet || echo " success"
    exit 0
else
    test $quiet || echo " FAILED!"
    exit 3
fi
============================================================



Reply to: