Programming and Scripting :: ISO image maker



First I just thought to add an alias, but then I found myself scripting...

In case anyone finds this useful... Does it work on DSL?
Code Sample
#!/bin/bash

# Bash script for making CD-images out of files and/or directories easily.
# Burned images should work with old CD drives as well with new ones
# and with many OS:es too.
# May not work if you specify multiple files/directories to add... But should.;)

# Copyright Zucca. Licence: public domain.

if [ -z "$1" ]
then
   echo "Nothing to do. --help for help." >&2
   exit 1
fi

case $1 in
   --help)
       echo -e "USAGE: `basename $0` [-bz] <imgfile> <contents for ISO image>\n -bz makes image compressed."
       echo "If \"imgfile\" is -, then output will be directed to stdout."
       ;;
   *)
   
   if [ -z "$2" ]
   then
       echo "Missing arguments." >&2
       exit 1
   elif which mkisofs &> /dev/null
   then
       
       MKISOFSOPTS="-JR -file-mode 0444 -dir-mode 0555"
       
       case $1 in
           -bz)
               # Zipping
               
               BZIPCOMMAND="bzip2 -vzc9"
               
               if [ -z "$3" ]
               then
                   echo "Missing arguments." >&2
                   exit 1
               elif ! which bzip2 &> /dev/null
               then
                   echo "bzip2 isn't in your \$PATH or isn't installed. Do not use -bz option" >&2
                   exit 1
               elif [ "$2" != "-" ]
               then
                   DESTFILE="$2"
                   shift
                   shift
                   # To file
                   mkisofs $MKISOFSOPTS $@ | $BZIPCOMMAND > $DESTFILE
               else
                   # To stdout
                   shift
                   shift
                   mkisofs $MKISOFSOPTS $@ | $BZIPCOMMAND
               fi
           ;;
           *)
               # No zipping
               DESTFILE="$1"
               shift
               case $DESTFILE in
                   -)
                       # To stdout
                       mkisofs $MKISOFSOPTS $@
                   ;;
                   *)
                       # To file
                       mkisofs $MKISOFSOPTS -o $DESTFILE $@
                   ;;
               esac
           ;;
       esac
   else
       echo "mkisofs isn't in your \$PATH or isn't installed." >&2
       exit 1
   fi
esac


I'd add a size limit there if I knew the precise size of 650Mb CD. Anyone know this?
Or any other suggestions?

I found a quite good page about the actual size of CD.

Here's in short:
Quote
Spelled out simply:


 21 minutes ==  94,500 sectors == 184.6MB CD-ROM == 212.0MB CD-DA
 63 minutes == 283,500 sectors == 553.7MB CD-ROM == 635.9MB CD-DA
 74 minutes == 333,000 sectors == 650.3MB CD-ROM == 746.9MB CD-DA
 80 minutes == 360,000 sectors == 703.1MB CD-ROM == 807.4MB CD-DA
 90 minutes == 405,000 sectors == 791.0MB CD-ROM == 908.4MB CD-DA
 99 minutes == 445,500 sectors == 870.1MB CD-ROM == 999.3MB CD-DA

What about DVDs then?

You can also use single quotes so that you don't have to escape certain characters on your output strings.

Any reason for making this a bash-specific script?

Quote (^thehatsrule^ @ Mar. 06 2008,11:40)
What about DVDs then?

You can also use single quotes so that you don't have to escape certain characters on your output strings.

Any reason for making this a bash-specific script?

I could add DVD image creating too.
Anyway. I designed this script primary for myself. Later I decided to share this.

Bash is common and I don't know much perl or any other language suitable for this. Well... I could do this with php, but then there would be php depency. ;P

I guess hats meant it has some bash-specific syntax, so it might or might not work with ash, dash, lash, etc. other shells. Though bash is a standard component, so you're likely to find it on any linux system.
Next Page...
original here.