#!/bin/sh

# Front end script for growisofs, to write an ISO or other
# image file to DVD

# Check command line arguments

if [ $# -ne 1 -o -z "$1" ]; then
  echo "Usage: dvdwrite <imagefile>"
  exit 1
fi

# Verify the image file exists

if [ ! -r "$1" ]; then
  echo "ERROR: DVD image file \"$1\" not found!"
  exit 1
fi

# Verify the DVD device node exists

if [ ! -b /dev/sr0 ]; then
  echo "ERROR: DVD device /dev/sr0 not found!"
  exit 1
fi

# Verify the growisofs program exists

if [ ! -x /usr/bin/growisofs ]; then
  echo "ERROR: growisofs program not found!"
  exit 1
fi

# Run growisofs to burn the image to DVD

growisofs -dvd-compat -Z /dev/sr0="$1"
