mirror of https://github.com/tLDP/LDP
54 lines
1.5 KiB
Bash
54 lines
1.5 KiB
Bash
#!/bin/bash
|
|
# copy-cd.sh: copying a data CD
|
|
|
|
CDROM=/dev/cdrom # CD ROM device
|
|
OF=/home/bozo/projects/cdimage.iso # output file
|
|
# /xxxx/xxxxxxxx/ Change to suit your system.
|
|
BLOCKSIZE=2048
|
|
# SPEED=10 # If unspecified, uses max spd.
|
|
# DEVICE=/dev/cdrom older version.
|
|
DEVICE="1,0,0"
|
|
|
|
echo; echo "Insert source CD, but do *not* mount it."
|
|
echo "Press ENTER when ready. "
|
|
read ready # Wait for input, $ready not used.
|
|
|
|
echo; echo "Copying the source CD to $OF."
|
|
echo "This may take a while. Please be patient."
|
|
|
|
dd if=$CDROM of=$OF bs=$BLOCKSIZE # Raw device copy.
|
|
|
|
|
|
echo; echo "Remove data CD."
|
|
echo "Insert blank CDR."
|
|
echo "Press ENTER when ready. "
|
|
read ready # Wait for input, $ready not used.
|
|
|
|
echo "Copying $OF to CDR."
|
|
|
|
# cdrecord -v -isosize speed=$SPEED dev=$DEVICE $OF # Old version.
|
|
wodim -v -isosize dev=$DEVICE $OF
|
|
# Uses Joerg Schilling's "cdrecord" package (see its docs).
|
|
# http://www.fokus.gmd.de/nthp/employees/schilling/cdrecord.html
|
|
# Newer Linux distros may use "wodim" rather than "cdrecord" ...
|
|
|
|
|
|
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
|
|
|
|
# Exercise:
|
|
# Change the above "case" statement to also accept "yes" and "Yes" as input.
|
|
|
|
exit 0
|