#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/sbin/mkcd/burn_cd_jodian.sh 1.8 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 1999,2006 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)87        1.8  src/bos/usr/sbin/mkcd/burn_cd_jodian.sh, cmdbsys, bos720 11/1/06 12:17:02
############################################################
##
## File:  burn_cd_jodian
##
## This is sample shell code for writing to a recordable 
## CD device using the Jodian software application, jiso2cd.
##
## If using this script with mkcd, this file must be linked 
## to /usr/sbin/burn_cd.  For example:
##    ln -s /usr/samples/oem_cdwriters/burn_cd_jodian /usr/sbin/burn_cd
##
## Parameters:  cd_device cd_image
##                use_dvd_flag (any non-zero parameter)
##                cd_device (i.e. /dev/cd0)
##                cd_image  (i.e. /mkcd/cd_images/cd_image_67890)
##
## Return Codes:  0 for successful
##                1 for unsuccessful
##
############################################################
export PATH="/usr/bin:/usr/sbin:$PATH"
MSGBUF=/tmp/.burn_cd.tmp.msg

if [ $# -eq 3 ]; then
   DVD_FLAG=$1      ## dummy variable to remain standard with mkcd
   CD_DEVICE=$2
   CD_IMAGE=$3
elif [ $# -eq 2 ]; then
   CD_DEVICE=$1
   CD_IMAGE=$2
else
   echo "Usage: burn_cd [-d] cd_device cd_image"
   echo "        -d flag for writing DVD images"
   echo " "
   echo "(-d flag included for compatibility with mkcd calling convention)"
   return 1
fi 

CD_DEVICE=`basename $CD_DEVICE`

############################################################
## If using a CD-RW writer, the following code can be
## uncommented to handle the erasing, before writing new
## data.  The pathname for jerase may need changing,
## depending on the system configuration.
############################################################
#echo "Erasing CD ..."
#/usr/jodian/jyamcdr/bin/jerase $CD_DEVICE

echo "Running jiso2cd ..."
/usr/jodian/jyamcdr/bin/jiso2cd -x 1 $CD_IMAGE $CD_DEVICE 2>$MSGBUF
if [ -s "$MSGBUF" ] && \
   [ `cat $MSGBUF | grep -ic error` -ne 0 ]; then
   cat $MSGBUF
   echo "burn_cd: Command error."
   rm -f $MSGBUF 2>/dev/null
   return 1
else
   echo "burn_cd was successful."
   rm -f $MSGBUF 2>/dev/null
   return 0
fi