[NTLUG:Discuss] Bye Bye Mickeysoft

kbrannen@gte.net kbrannen at gte.net
Tue Jan 28 15:28:48 CST 2003


terry wrote:
> kbrannen at gte.net wrote:
> 
>> TJ Davis wrote:
> 
> 
> ---<snip>---
> 
>>   I just cd to that dir and as root run "mkcd", it does everything 
>> automatically.  You're welcome to the script if you want it.
> 
> 
> I'd like that script.

OK, since I've had several other requests, I might as well head any others at 
the pass and just post it.

It's a KSH script, so you'll need /bin/ksh (or /usr/bin/ksh).  It probably 
should be bash compatible, but I haven't bothered to check (I personally 
prefer ksh over bash).  It should be easy to convert if you don't have ksh.

For those of you to whom I've already emailed the script, you probably want to 
use this version.  I've added a little error checking.

There are 5 configuration vars at the top of the script, look for "export". 
There is a comment with each to help you.  Set it to what you need.  If your 
burner is using the SCSI emulation layer and it is the only device doing so, 
then the device value may be correct for you too; but if you read the cdrecord 
man page it says you can do "cdrecord -scanbus" to find out.

At the bottom of the script just above the cdrecord command, it says that you 
can add the "-dummy" flag to test with.  I hightly suggest you do that until 
you're sure you have the all the config vars set correctly.

I use this for archiving data, especially backups.  Hence the way it is 
written.  However, cdrecord will also support normal audio (e.g. music).  I'll 
leave that (and potentially optional args to tell mkcd that's what is wanted) 
to the reader. :-)

BTW, be careful of the mailer, that last line with the cdrecord command is 1 
long line, even if it does get wrapped.

Kevin

----------------------------------------------------------------------

#!/bin/ksh
# mkcd:  This script allows you to make a CD.  Get all the data files you
#        you want to archive into a single directory, then as root, cd to
#        that directory and run this script.
#
#        Note that it is interactive.  After it makes the ISO image, it tries
#        to show you the ISO image and a quick top level listing of the ISO
#        to help you know that you started the command at the correct place.
#        If you want this script to be fully automated, then comment out at
#        least the "read" line, and probably the 5 lines above it.

# comment this next line out if you don't want to see the commands it uses
set -x

# set this to a place where you *KNOW* you will always have 750M free
export backup_dir="/backup/tmp"
# CD burner device
export device="1,0,0"
# recording speed
export speed="12"
# recording buffer size
export buffer="8m"
# max CD size (minus a little)
export maxcd="695000"

# quick error checking
if [[ $(whoami) != root ]]
then
         print "You must be root run this!";
         exit 1
fi
sz=`du -s . | awk '{ print $1 }'`
echo computed $sz kbytes in the dir
if [[ $sz = 0 ]]
then
         echo 'The directory is empty?  Aborting!'
         exit 1
fi
if [[ $sz > $maxcd ]]
then
         echo "The directory contains more than $maxcd Kbytes.  Aborting!"
         exit 1
fi

# -v  verbose, tell us what it's doing
# -l  allow 32 char filenames
# -J  generate Joliet filenames
# -L  allow filenames to begin with a .
# -T  generate TRANS.TBL, a file in each dir to help establish
#     the correct file names
# -A "string"  what to put in the application identifier area, 128 chars
# -p "string"  what to put in the preparer area, 128 chars
# -P "string"  what to put in the publisher area, 128 chars
# -V "string"  what to put in the volume identifer area, 32 chars
# must have -R & -o <file>
mkisofs -v -l -J -L -R -o $backup_dir/cdimage.raw .

# we can look at the image by doing:
ls -l $backup_dir/cdimage.raw
mount $backup_dir/cdimage.raw -r -t iso9660 -o loop /mnt
ls -l /mnt
umount /mnt
echo "look good?  <return> or ^C"
read line

# to test add "-dummy" arg
#cdrecord -multi -v -fs=8m -dev=1,0,0 -speed=12 -data isoimage
cdrecord -multi -v -fs=$buffer -dev=$device -speed=$speed -data 
$backup_dir/cdimage.raw
----------------------------------------------------------------




More information about the Discuss mailing list