#!/bin/bash #Ryan Pisani - March, 20th 2010 #Please give feedback to mythdora@thepisanis.com PATH=/bin:/sbin:/usr/sbin:/usr/bin #Incoming options ISO="$1" COUNT="$2" SCRIBE="3" if [[ ! -e $ISO || -z $COUNT ]]; then echo "Usage: $0 /path/to/image.iso count" exit fi #Get basename of the iso file to use in caches ISONAME=$(basename $ISO) #Determine how many writers we have DRIVES=($(ls /dev/sr* | grep -v sr0)) #DRIVES=($(ls /dev/sr*)) DRIVECOUNT=$(echo $DRIVES | wc -w) #Check to see if there is a cache file setup already for the iso if [[ ! -d "$HOME/.bulk-burn" ]]; then mkdir -p $HOME/.bulk-burn fi #Check to see if the cache exists for this iso, if not we create one if [[ ! -e "$HOME/.bulk-burn/$ISONAME.isosum" ]]; then #echo that we're generating md5sums echo -e "\nGenerating md5sum & block counts for the ISO. This may take a bit..\n" #First get md5 information on the target iso to be used later in verification ISOSUM=$(md5sum $ISO | awk '{print $1}') ISOBLKS=$(ls -l $ISO | awk '{print $5}') BLKCNT=$(echo $[ISOBLKS / 2048]) echo "$ISOSUM" >$HOME/.bulk-burn/$ISONAME.isosum echo "$BLKCNT" >$HOME/.bulk-burn/$ISONAME.blkcnt else #Retrieve the existing values ISOSUM=$(cat $HOME/.bulk-burn/$ISONAME.isosum) BLKCNT=$(cat $HOME/.bulk-burn/$ISONAME.blkcnt) fi echo -e "\nMD5SUM: $ISOSUM BLOCKS: $ISOBLKS BLKCNT: $BLKCNT\n" #lets start burning the images while [[ $COUNT -gt 0 ]]; do for DRIVE in ${DRIVES[@]}; do if [[ $COUNT -gt 0 ]]; then DRV=$(basename $DRIVE) #Check to see if a disk is there already if ! ( lshal | grep -A1 volume_empty_dvd_r | grep block.device | grep $DRIVE ); then echo "Please insert a blank disk into $DRIVE" eject $DRIVE read -p "Press enter to continue" fi until [[ ! -e "/var/tmp/lock.$DRV" ]]; do echo "Waiting for $DRIVE to be free" sleep 30 done #Write the disk and background it so we can move on to another disk (touch /var/tmp/lock.$DRV; growisofs -Z $DRIVE=$ISO; echo -e "\nVerifying burned disk.. this may take a few minutes\n" BRNSUM=$(dd if=$DRIVE bs=2048 count=$BLKCNT 2>/dev/null| md5sum | awk '{print $1}'); echo -e "$DRIVE:\nISO:$ISOSUM\nDisk:$BRNSUM\n" if [[ $BRNSUM != $ISOSUM ]]; then echo "Burn on drive $DRIVE failed to verify" fi rm -rf /var/tmp/lock.$DRV; eject $DRIVE) #& #uncomment ampersan to allow concurrent background writing on multiple drives fi sleep 30; let COUNT="$COUNT - 1" done done #Lets wait for child processes to exit before we exit wait #TARGET=$(lshal -u /org/freedesktop/Hal/devices/volume_empty_dvd_r | grep block.device | awk -F"'" '{print $2}' | awk -F"'" '{print $1}')