LDP/LDP/guide/docbook/abs-guide/copy-cd.sh

54 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
# copy-cd.sh: copying a data CD
CDROM=/dev/cdrom # CD ROM device
OF=/home/bozo/projects/cdimage.iso # output file
2008-11-23 22:43:47 +00:00
# /xxxx/xxxxxxxx/ Change to suit your system.
2001-07-10 14:25:50 +00:00
BLOCKSIZE=2048
2009-03-24 18:46:05 +00:00
# SPEED=10 # If unspecified, uses max spd.
# DEVICE=/dev/cdrom older version.
DEVICE="1,0,0"
2001-07-10 14:25:50 +00:00
echo; echo "Insert source CD, but do *not* mount it."
echo "Press ENTER when ready. "
2001-09-04 13:27:31 +00:00
read ready # Wait for input, $ready not used.
2001-07-10 14:25:50 +00:00
echo; echo "Copying the source CD to $OF."
echo "This may take a while. Please be patient."
2001-09-04 13:27:31 +00:00
dd if=$CDROM of=$OF bs=$BLOCKSIZE # Raw device copy.
2001-07-10 14:25:50 +00:00
echo; echo "Remove data CD."
echo "Insert blank CDR."
echo "Press ENTER when ready. "
2001-09-04 13:27:31 +00:00
read ready # Wait for input, $ready not used.
2001-07-10 14:25:50 +00:00
echo "Copying $OF to CDR."
2009-03-24 18:46:05 +00:00
# cdrecord -v -isosize speed=$SPEED dev=$DEVICE $OF # Old version.
wodim -v -isosize dev=$DEVICE $OF
2001-07-10 14:25:50 +00:00
# Uses Joerg Schilling's "cdrecord" package (see its docs).
2001-09-04 13:27:31 +00:00
# http://www.fokus.gmd.de/nthp/employees/schilling/cdrecord.html
2008-11-23 22:43:47 +00:00
# Newer Linux distros may use "wodim" rather than "cdrecord" ...
2001-07-10 14:25:50 +00:00
echo; echo "Done copying $OF to CDR on device $CDROM."
echo "Do you want to erase the image file (y/n)? " # Probably a huge file.
read answer
case "$answer" in
[yY]) rm -f $OF
echo "$OF erased."
;;
*) echo "$OF not erased.";;
esac
echo
2002-04-01 16:04:17 +00:00
# Exercise:
2001-07-10 14:25:50 +00:00
# Change the above "case" statement to also accept "yes" and "Yes" as input.
exit 0