Debian Codegraph @

copy-cd.sh

raw symbols SCIP
1 #!/bin/bash
2 # copy-cd.sh: copying a data CD
3
4 CDROM=/dev/cdrom # CD ROM device
5 OF=/home/bozo/projects/cdimage.iso # output file
6 # /xxxx/xxxxxxxx/ Change to suit your system.
7 BLOCKSIZE=2048
8 # SPEED=10 # If unspecified, uses max spd.
9 # DEVICE=/dev/cdrom older version.
10 DEVICE="1,0,0"
11
12 echo; echo "Insert source CD, but do *not* mount it."
13 echo "Press ENTER when ready. "
14 read ready # Wait for input, $ready not used.
15
16 echo; echo "Copying the source CD to $OF."
17 echo "This may take a while. Please be patient."
18
19 dd if=$CDROM of=$OF bs=$BLOCKSIZE # Raw device copy.
20
21
22 echo; echo "Remove data CD."
23 echo "Insert blank CDR."
24 echo "Press ENTER when ready. "
25 read ready # Wait for input, $ready not used.
26
27 echo "Copying $OF to CDR."
28
29 # cdrecord -v -isosize speed=$SPEED dev=$DEVICE $OF # Old version.
30 wodim -v -isosize dev=$DEVICE $OF
31 # Uses Joerg Schilling's "cdrecord" package (see its docs).
32 # http://www.fokus.gmd.de/nthp/employees/schilling/cdrecord.html
33 # Newer Linux distros may use "wodim" rather than "cdrecord" ...
34
35
36 echo; echo "Done copying $OF to CDR on device $CDROM."
37
38 echo "Do you want to erase the image file (y/n)? " # Probably a huge file.
39 read answer
40
41 case "$answer" in
42 [yY]) rm -f $OF
43 echo "$OF erased."
44 ;;
45 *) echo "$OF not erased.";;
46 esac
47
48 echo
49
50 # Exercise:
51 # Change the above "case" statement to also accept "yes" and "Yes" as input.
52
53 exit 0