#!/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/usr/sbin/mkcd/burn_cd_gnu.sh 1.12 # # 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 # @(#)86 1.12 src/bos/usr/sbin/mkcd/burn_cd_gnu.sh, cmdbsys, bos720 11/1/06 12:00:51 ############################################################ ## ## File: burn_cd_gnu ## ## This is sample shell code for writing to a recordable ## CD device using the GNU software application, cdrecord. ## ## 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_gnu /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 MSGBUF2=/tmp/.burn_cd.tmp.msg2 ON=1 OFF=0 DVD_FLAG=$OFF NAME="burn_cd" rm -f $MSGBUF2 ## Two possible locations for cdrecord and readcd [[ -s /usr/bin/cdrecord ]] && CD_RECORD_PATH=/usr/bin || CD_RECORD_PATH=/usr/local/bin if [ $# -eq 3 ]; then DVD_FLAG=$1 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 for writing DVD images" return 1 fi ############################################################ ## The cdrecord routine requires the device in format 1,0 ## where 1 is the CD device number associated with the name, ## and 0 is the logical unit number (i.e. /dev/cd1 = 1,0). ############################################################ DEVICE=$CD_DEVICE CD_DEVICE="`basename $CD_DEVICE |sed 's/cd//'`,0" ############################################################ ## If writing to a rewritable CD on a CD-RW device, the ## "blank" parameter can be added to the cdrecord call, for ## erasing the CD before writing. ## For example: blank=fast ############################################################ if [ $DVD_FLAG = $OFF ];then ## create CD image echo "Running cdrecord ..." $CD_RECORD_PATH/cdrecord dev=$CD_DEVICE speed=1 $CD_IMAGE 2>$MSGBUF else ## create DVD image echo "Running readcd ..." $CD_RECORD_PATH/readcd -w dev=$CD_DEVICE f=$CD_IMAGE 2>$MSGBUF >$MSGBUF2 fi if [ $? -ne 0 ]; then echo "" cat $MSGBUF2 cat $MSGBUF echo "" /usr/bin/dspmsg -s 5 mksysb.cat 93 \ "0512-332 $NAME: Device $DEVICE does not appear to be ready. For information about possible causes, see /usr/lpp/bos.sysmgt/mkcd.README.txt Continuing...\n" $NAME $DEVICE echo "" echo "burn_cd: Command error." rm -f $MSGBUF $MSGBUF2 return 1 else echo "" cat $MSGBUF2 echo "burn_cd was successful." rm -f $MSGBUF $MSGBUF2 return 0 fi