#!/bin/sh # cd2iso read CD to iso image # CDROM=/dev/cdrom # Default device # Help if [ "$1" = "" ] then echo " cd2iso 1.01 dump CD to an iso file Copyright (C) 2003: Manel Marin Licence: GNU GPL version >= 2 Use: cd2iso filename.iso # Asumes /dev/cdrom as input cd2iso filename.iso /dev/hdd " exit 0 fi # Get device if given if [ "$2" != "" ] then CDROM=$2 fi # Check isoinfo present if ! which isoinfo > /dev/null then echo "isoinfo is not present, please install package: mkisofs" exit 2 fi echo "----" isoinfo -d -i $CDROM echo "----" # Calculate isosize from isoinfo data. ISOSIZE="" ISOSIZE=$(isoinfo -d -i $CDROM | awk ' BEGIN { volume=0 } /[Vv]olume.*number/ { gsub( /.*: */, "" ); volume=$0 } /[bB]lock size/ { gsub( /.*: */, "" ); blocksize=$0 } /[Vv]olume size/ { gsub( /.*: */, "" ); volumesize=$0 } END { # NOTE 1.01: Volume number could not be present == 1 if( volume == 0 && (blocksize == 0 || volumesize == 0)){ print "" # No data available: ERROR exit } if( volume > 1 ) print "0" # more than 1 volume return 0 else print blocksize * volumesize # return isosize } ') if [ "$ISOSIZE" = "" ] then echo "ABORTING: Some error ocurred while piping isoinfo via awk..." exit 2 elif [ "$ISOSIZE" = 0 ] then echo "More than 1 volume in CDROM, it can not be dump to an ISO file" exit 1 else echo "Dumping $ISOSIZE bytes from $CDROM to file" echo "Please be patient..." #head --bytes=`isosize /dev/cdrom` < /dev/cdrom > $1 nice head --bytes=$ISOSIZE < $CDROM > $1 fi