#!/usr/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/sbin/mkcd/burn_cd_youngminds.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 
# @(#)88        1.8  src/bos/usr/sbin/mkcd/burn_cd_youngminds.sh, cmdbsys, bos720 11/1/06 12:28:22
############################################################
##
## File:  burn_cd_youngminds
##
## This is sample shell code for writing to a recordable 
## CD device using the Young Minds, Inc. software 
## application, ymicntl.sh.
##
## 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_youngminds /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:/etc:$PATH"
MSGBUF=/tmp/.burn_cd.tmp.msg

if [ $# -eq 3 ]; then
   DVD_FLAG=$1       ## dummy variable to remain standard with mkcd
   YM_DEVICE=$2
   CD_IMAGE=$3
elif [ $# -eq 2 ]; then
   YM_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

echo "Copying image to Young Minds CD Studio..."
dd if=$CD_IMAGE of=$YM_DEVICE bs=30b conv=sync 2>$MSGBUF
if [ $? -ne 0 ]; then
   cat $MSGBUF
   echo "burn_cd: Command error."
   rm -f $MSGBUF
   return 1
fi

echo "Please wait about 1 minute after the CD device light goes out\n\
before removing the CD from the drive."

echo "Sending image to Young Minds CD writing device..."
/usr/local/makedisc/ymicntl.sh -f $YM_DEVICE cut 2>$MSGBUF
if [ $? -ne 0 ]; then
   cat $MSGBUF
   echo "burn_cd: Command error."
   rm -f $MSGBUF
   return 1
else
   echo "burn_cd was successful."
   rm -f $MSGBUF
   return 0
fi
