#!/bin/sh
# Written by Katja and Guido Socher
# vim: set sw=4 ts=4 et:
# 
# 2002-03-10: handle abs path for image file
#
help()
{
  cat <<HELP
mkisofseasy -- create an iso image for writing to CDrom 

USAGE: mkisofseasy image.file dir_with_input_files

EXAMPLE: mkisofseasy image.file /home/katja/photos
Explanation: The image.file will be created and the data for it 
will be read from /home/katja/photos
The directory /home/katja/photos will be come the root directory of
the CD. That is: this directory level will not be included.

The created image file is made with joliet and  Rock Ridge extensions.
It preserves long file names and will be readable under Linux and
under windows.

You can preview your CD before burning with the following command:
mount -o loop -t iso9660 image.file /some/directory

HELP
  exit 0
}

error()
{
    # print an error and exit
    echo "$1"
    exit 1
}

# The option parser, change it as needed
# In this example -f and -h take no arguments -l takes an argument
# after the l
while [ -n "$1" ]; do
case $1 in
    -h) help;shift 1;; # function help is called
    --) shift;break;; # end of options
    -*) echo "error: no such option $1. -h for help";exit 1;;
    *)  break;;
esac
done
[ -z "$2" ]&& help
# The main program of you script comes after this line
pwd=`pwd`
if echo "$1" | grep '^/' > /dev/null 2>&1; then
    # abs path:
    image="$1"
else
    # rel path:
    image="$pwd/$1"
fi
cd $2
echo "Your CD image will contain the following files:"
find . -print
echo "-----------------------------------------------"
echo "writing image to $image ..."
mkisofs -o $image -r -J .
#
