# ex40.sh (burn-cd.sh)
# Script to automate burning a CDR.
SPEED=10 # May use higher speed if your hardware supports it.
# DEVICE=/dev/cdrom For older versions of cdrecord
DEFAULTDIR=/opt # This is the directory containing the data to be burned.
# Make sure it exists.
# Exercise: Add a test for this.
# Uses Joerg Schilling’s “cdrecord” package:
# If this script invoked as an ordinary user, may need to suid cdrecord
#+ chmod u+s /usr/bin/cdrecord, as root.
# Of course, this creates a security hole, though a relatively minor one.
if [ -z “$1” ]
# Default directory, if not specified on command-line.
# Create a “table of contents” file.
ls -lRF $IMAGE_DIRECTORY > $IMAGE_DIRECTORY/$CONTENTSFILE
# The “l” option gives a “long” file listing.
# The “R” option makes the listing recursive.
# The “F” option marks the file types (directories get a trailing /).
echo “Creating table of contents.”
# Create an image file preparatory to burning it onto the CDR.
mkisofs -r -o $IMAGEFILE $IMAGE_DIRECTORY
echo “Creating ISO9660 file system image ($IMAGEFILE).”
# Burn the CDR.
echo “Burning the disk.”
echo “Please be patient, this will take a while.”
wodim -v -isosize dev=$DEVICE $IMAGEFILE
# In newer Linux distros, the “wodim” utility assumes the
#+ functionality of “cdrecord.”
echo “Exit code = $exitcode”
Posted in Linux, Recent Posts and tagged Burning iso image by Stan with .