#!/bin/bash # # Original File # ------------- # http://www.Linux-1U.net/CDRW/scripts # # # Script to Write CDROMs # # # 20-Nov-02 amo Local copy from Starshine.org # # # . | . Heather Stern | star@starshine.org # --->*<--- Starshine Technical Services - * - consulting@starshine.org # ' | ` Sysadmin Support and Training | (800) 938-4078 # # # this script. # A wrapper for mkisofs since I hate typing piles of options. # I like to just prepare the source tree and let it COOK. # # see also BURN for putting the result onto a CD. # # me. # Heather Stern, Starshine Technical Services # I'm a consultant in linux and other free software. I've been # doing this for a long time; ask any search engine :) # # if you want to hire me contact or call # (800 938 4078) and leave a message. # # license. # BSD modern. # Take this shell script and copy it anywhere you want. iF you break # something THERE IS NO WARRANTY. NOT EVEN IMPLIED.. # If you change this script, I still expect credit for my portion, but # you need to label what you add; your bugs are your problem. # # usage. # Create your cdrom directory structure, with subdirs 'eltorito' for # your boot floppies (if any), and 'cd-parts' for the descriptive fluff. # (More detail below.) # # dependencies. # I don't believe this is all that version-bound, but here's what I'm # using on the system this was written for. # # mkisofs 1.15a12 (i686-suse-linux) # # GNU bash, version 2.05.0(1)-release (i386-suse-linux) # Copyright 2000 Free Software Foundation, Inc. # # changelog. # v 1.0.0 completed Wed Oct 23 04:15:37 PDT 2002 # accepts the directory, checks for two subdirs, gathers up boot image # names, support for tack-on options to pass through. # # todo. # Accept "+" for "use all files in the eltorito directory as boot floppies" # ...though admittedly then you can't pick the order. sort by size? # Naming convention to recognize hard-disk images, which want an extra param # Some smarts about whether "file" really thinks the images are boot sectors? # ...it should accept binary data, too, in case of no-emu images. # ...probably would have a dependency on awk? # echo "COOK: a mkisofs wrapper, v 1.0.0. Heather Stern " echo "Modern BSD license. Source? of course! It's a *shell script* ..." # ::: # for debugging, set this to echo #MKISOFS="echo mkisofs" MKISOFS="/usr/bin/mkisofs" # ::: anytime we bail, spit out the usage statement usage(){ echo <<'usage-done' Usage: $0 [[]...] [-- ] --help, -h, or -? alone on the commandline brings up this help. This program is a wrapper around mkisofs. It expects that the source tree has already been prepared, and has a directory named cd-parts containing these files: application (128 character limit) copyright (37 character limit) publisher (128 character limit) preparer (128 character limit) volume_id (used as mountpoint / disc name) boot.catalog (a 0 byte file would be fine) It may also contain a irectory named eltorito, containing your floppy images. Thus you only need to specify the floppy names themselves. If the command line contains -- then all items after that are gathered into a variable to pass to mkisofs in addition to default options this wrapper provides. By default Joliet and Rock Ridge extensions are honored to allow normal filenames, and the resulting disc image is placed in /usr/src/cooked.iso. usage-done } # ::: check for the destination if [ $# -lt 1 ] then echo "$0 needs a directory to make a cdrom image from." echo usage exit 1 fi if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "-?" ]] then usage exit 254 fi # ::: first parameter: directory if [ ! -d "$1" ] then echo "$0 needs a directory to make a cdrom image from." echo "$1 is not a directory." echo usage exit 10 fi DST="$1" shift if [ ! -d "$DST/cd-parts" ] then echo "$0 expects some small files in $1/cd-parts." echo "$1/cd-parts is not a directory." echo usage exit 11 fi # ::: boot images, until bored, or we encounter -- # if no options are given, the disc won't be bootable BOOTIMAGE="-no-boot" export BOOTIMAGE if [ $# -ge 1 ] then if [ ! -d "$DST/eltorito" ] then echo "$0 expects boot images to be placed in $DST/eltorito." echo "$DST/eltorito is not a directory." echo usage exit 20 fi BCOUNT="0" export BCOUNT BAD="0" export BAD for i in $@ do if [ "$i" == "--" ] then # stop gathering boot names break fi if [ "$BCOUNT" -eq "0" ] then if [[ -f "$DST/eltorito/$i" && -r "$DST/eltorito/$i" ]] then BOOTIMAGE="-b eltorito/$i" BCOUNT=$(( $BCOUNT + 1 )) else echo "Warning! $i was not a readable, normal file" BAD=$(( $BAD + 1 )) fi else # extra boot images, same treatment, dif't preamble. if [[ -f "$DST/eltorito/$i" && -r "$DST/eltorito/$i" ]] then BOOTIMAGE="$BOOTIMAGE -eltorito-alt-boot -b eltorito/$i" BCOUNT=$(( $BCOUNT + 1 )) else echo "Warning! $i was not a readable, normal file" BAD=$(( $BAD + 1 )) fi fi done shift $BCOUNT shift $BAD echo # end / we had any extra parameters to use as boot images fi if [ "$BOOTIMAGE" == "-no-boot" ] then echo "Warning! This disc will not be bootable. Some machines can't tell..." else echo "There were $BCOUNT readable images listed and $BAD problem filenames." fi # ::: if there's any extra options, gather them up too. if [[ $# -ge 1 && "$1" == "--" ]] then shift BOOTIMAGE="$@" echo "Extra options accepted." else echo "No extra options. That's fine." fi # ::: you're still here? well let's get to it then! # note that the dot on the end is significant; we move into the source, # then we use it. cd $DST $MKISOFS $BOOTIMAGE -c cd-parts/boot.catalog \ -J -R -hide-joliet-trans-tbl -hide-rr-moved -T \ -A cd-parts/application -copyright cd-parts/copyright \ -P cd-parts/publisher -p cd-parts/preparer -V cd-parts/volume_id \ -log-file /usr/src/mkisofs.errors $EXTRAOPTIONS \ -o /usr/src/cooked.iso . # ::: now take us back to where we came from cd - # # End of file