Home

easycd.sh




Purpose

easycd.sh is a wrapper script for cdrecord


Back to top

License


# CDDL HEADER START
#
# The contents of this file and the script are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END


Back to top

History


Version
Releasedate
         Description
0.02
02/2005

0.03
11.05.2005
still work in progress, but with less bugs






Back to top

Operating system

Solaris


Back to top

Language / type

Kornshell Script


Back to top

Prerequisites

cdrecord, cdrecord-prodvd, mkisofs, readcd, and cdda2wav.

You must be root to execute this script


Back to top

Usage


bash-2.05# ./easycd.sh -v  -h
[11.05.2005 22:56:40] Default action is create an ISO image and burn it to CD
[11.05.2005 22:56:40] easycd started on Wed May 11 22:56:40 MDT 2005 
  easycd 0.03 -  wrapper script for cdrecord & co

  Usage: easycd [-v] [-q] [-h] [-l logfile] [-y] [-n] [-D]
                   [-a {y|n}] [-O {y|n}] [-H] [-V] [-R]
                   [-f] [-b] [-t] [-e] [-d] [-N] [-s writerspeed,readerspeed]
                   [-m] [-r] [-w] [-x action] [parameter] 
    Parameter:

      -x - action, action can be:
               install [configfile]
               uninstall
               createISOimg sourcedir [isofile] [volid]
               writecdrom|writecd sourcedir [volid]
               writedvd sourcedir [volid]
               readcdrom|testcd isofile [srcdevice]
               readdvd isofile [srcdevice]
               burncdrom|burncd isofile
               burndvd isofile
               clonecdrom|clonecd [srcdevice]
               clonedvd  [srcdevice]
               copycdrom|copycd [srcdevice]
               copydvd  [srcdevice]
               copyaudiocd [srcdevice] [useCDDB]
               readaudiocd [targetdir] [sourcedevice] [useCDDB]
               writeaudiocd [sourcedir] [targetdevice]
               blankcdrom|blankcd [blanktype]
               blankdvd [blanktype]
               ejectcdrom|ejectcd [device]
               ejectdvd [device]
               loadcdrom|loadcd [device]
               loaddvd [device]
               testcdrom|testcd [sourcedevice]
               testdvd [sourcedevice]
               testiso isofile
               listcdrom|listcd [sourcedevice]
               listdvd [sourcedevice]
               listiso isofile
               verifycdrom|verifycd [device]

      -f - switch the "write the CD/DVD on the fly" flag
           Current Status is n
      -b - switch the "blank the CD/DVD before burning" flag
           Current Status is n
      -t - switch the "test the CD/DVD after burning" flag
           Current Status is n
      -V - switch the "verify the CD/DVD after burning" flag
           Current Status is n
      -R - switch the "relaod the CD/DVD before doing anything" flag
           Current Status is n
      -L - switch the "list the CD/DVD after burning" flag
           Current Status is n
      -e - switch the "eject the CD/DVD after burning" flag
           Current Status is y
      -d - switch the "write the CD/DVD in dummy mode" flag
           Current Status is n
      -N - switch the "do NOT check the directory size of the source dir" flag
           Current Status is y
      -s - set the writer and/or reader speed
           Default: 4,48
      -m - process multi disks
           Current Status is n
      -r - switch the "remove the ISO image after burning" flag
           Current Status is n

      -w - switch the "wait for user pressing return before ending the script" flag
           Current Status is n

      -v - turn verbose mode on
      -q - turn quiet mode on
      -h - show usage
      -l - set the logfile
           Def.: /var/tmp/easycd.24516.LOG
      -y - assume yes to all questions
      -n - assume no to all questions
      -D - run main in single step mode (and turn colors on)
      -a - turn colors on (y) or off (n), Default: y
      -O - overwrite existing files (y) or not (n), Default: n

      -H - write extended usage to STDERR

    Use the environment variables DVDRECORD_OPTIONS, CDRECORD_OPTIONS
    MKISOFS_OPTIONS, READCD_OPTIONS, and CDDA2WAV_OPTIONS for additional
    parameter for dvdrecord, cdrecord, mkisofs, readcd, or cdda2wav.

    The file "/opt/scripts/dvdoptions" must contain the license key for
    dvdrecord/cdrecord.

    The config file "easycd.conf" is searched in the current
    directory and in the HOME directory (in this order).

    Use "easycd.sh -x install" to create the symbolic links in the
    current directory; use "easycd.sh -x uninstall" to remove the
    symbolic links in the current directory.

[11.05.2005 22:56:41] The log file used was "/var/tmp/easycd.24516.LOG.24516.TEMP"
[11.05.2005 22:56:41] easycd ended on Wed May 11 22:56:41 MDT 2005.
[11.05.2005 22:56:41] The RC is 1.
bash-2.05#

Back to top

Examples



Back to top

Notes

Use

./easycd.sh -x install

to create the symbolic links and the config file. easycd.sh will create a config file called easycd.conf in your home directory. The config file looks like this:

# config file for ./easycd
#
# default parameter for mkisofs, cdrecord, dvdrecord, and readcd
#
# Note: Use a config file to change these values
#

# default options for mkisofs
  DEFAULT_MKISOFS_PARM="-D -hide-rr-moved -hide-joliet-trans-tbl -v -v -J -R -l -L -d -N -U -f -no-iso-translate -relaxed-filenames"
 
# default options for cdrecord for burning CDs 
  DEFAULT_CDRECORD_PARM="driveropts=burnfree gracetime=2  "

# default options for cdrecord for burning DVDs 
  DEFAULT_DVDRECORD_PARM="driveropts=burnfree gracetime=2  "

# default blank mode for CDs and DVDs
  DEFAULT_BLANK_PARM="fast"

# default cdrecord parameter to eject a CD/DVD
  DEFAULT_EJECT_PARM="-eject gracetime=2"

# default cdrecord parameter to load a CD/DVD
  DEFAULT_LOAD_PARM="-load gracetime=2"

# default parameter for readcd to read CDs and/or DVDs
  DEFAULT_READCD_PARM=""

# default parameter for cdda2wav
  DEFAULT_CDDA2WAV_PARM="-vall -B -Owav"

# use the cddb (y) or not (no) for reading/copying audio cds
  DEFAULT_USE_CDDB="y"
 
# binaries used

# binary for burning DVDs
  DVDRECORD_BINARY="/usr/bin/cdrecord-prodvd"

# binary for burning CDs
  CDRECORD_BINARY="/opt/csw/bin/cdrecord"
 
# binary to create an ISO image
  MKISOFS_BINARY="/opt/csw/bin/mkisofs"

# binary to read a data CD
  READCD_BINARY="/opt/csw/bin/readcd"

# binary to read an audio CD
  CDDA2WAV_BINARY="/opt/csw/bin/cdda2wav"

# option file for dvdrecord/cdrecord with the license key
  DVD_OPTION_FILE="/opt/scripts/dvdoptions"

# directories 

# default base directory for source directories
  IMG_SOURCE_BASE_DIR="/var/cdimg/dir"

# default base directory for ISO images and audio file directories
  IMG_TARGET_DIR="/var/cdimg/iso"

# default file for logfiles from mkisofs
  LOG_DIR="/var/cdimg/log"

# time in seconds to wait until vold finish after stopping
  VOLD_WAIT_TIME=5

  __WRITER_SCSI_ID=3
  __READER_SCSI_ID=2

# cdrom write device parameter for cdrecord/dvdrecord
    WRITER_DEV="USCSI:0,${__WRITER_SCSI_ID},0"

# cdrom reader device parameter for cdrecord/dvdrecord
    READER_DEV="USCSI:0,${__READER_SCSI_ID},0"

# raw devices for the reader
   WRITER_RAW_DEVICE="/dev/rdsk/c0t${__WRITER_SCSI_ID}d0s0"

# raw devices for the writer
   READER_RAW_DEVICE="/dev/rdsk/c0t${__READER_SCSI_ID}d0s0"

# device for mounting the CD/DVD in the burner
   WRITER_DEVICE="/dev/dsk/c0t${__WRITER_SCSI_ID}d0s0"

# device for mounting the CD/DVD in the reader
   READER_DEVICE="/dev/dsk/c0t${__READER_SCSI_ID}d0s0"

# default reader device
  DEFAULT_SOURCE_DEVICE=${READER_DEVICE}
 
# default write device
  DEFAULT_TARGET_DEVICE=${WRITER_DEVICE}

# default write speed
  DEFAULT_WRITER_SPEED="10"

# default reader speed
  DEFAULT_READER_SPEED="48"
   
# default action
  DEFAULT_ACTION="writecdrom"

# defaults for the modifier
  DEFAULT_WRITE_ON_THE_FLY=${__FALSE}
  DEFAULT_BLANK_THE_MEDIUM=${__FALSE}
  DEFAULT_TEST_THE_MEDIUM=${__FALSE}
  DEFAULT_LIST_THE_MEDIUM=${__FALSE}
  DEFAULT_EJECT_THE_MEDIUM=${__FALSE}
  DEFAULT_DUMMY_MODE=${__FALSE}
  DEFAULT_CHECK_DIR_SIZE=${__TRUE}
  DEFAULT_REMOVE_ISO_IMAGE=${__FALSE}
  DEFAULT_WAIT_FOR_USER=${__FALSE}

# c = CDROM/CDRW, - = DVD/DVD-RW
  DEFAULT_USE_DVD="c"


Edit the file to your need.

The symoblic links created in the current directory are:

bash-2.05# ls -l | grep easycd
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 blankcd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 blankdvd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 cdrecord -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 copyaudiocd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 copycd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 copy_cd_to_iso_img -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 copyddvd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 copy_dir_to_iso_img -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 copy_dvd_to_iso_img -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 24 14:25 create_iso_img -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 24 14:25 dvdrecord+ -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 dvdrecord- -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 dvdrecord -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 easycd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 easydvd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 ejectcd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 ejectdvd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 loadcd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 loaddvd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 readaudiocd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 testcd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 testdvd -> ./easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 testiso -> ./easycd.sh
lrwxrwxrwx   1 root     other         22 Apr  5 21:23 verifycd -> /var/develop/easycd.sh
lrwxrwxrwx   1 root     other         22 Apr  5 21:23 verifydvd -> /var/develop/easycd.sh
lrwxrwxrwx   1 root     other         11 Dec 30 00:14 writeaudiocd -> ./easycd.sh


easycd.sh uses different default values if called via an symbolic link (see the source code for more infos).


You may also create config files for the symbolic links:

bash-2.05# ./testiso -x install
[09.02.2005 20:38:20] Default action is test an ISO image
[09.02.2005 20:38:21] testiso started on Wed Feb  9 20:38:21 MET 2005 
[09.02.2005 20:38:21] Using the log file "/var/tmp/testiso.11084.LOG" 
[09.02.2005 20:38:21] Reading "/opt/scripts/dvdoptions" ...
[09.02.2005 20:38:21] Action selected is "install" 
[09.02.2005 20:38:21] Using the recording binary "/opt/csw/bin/cdrecord" ...
[09.02.2005 20:38:21] Writing the config file "/root/testiso.conf" ...
[09.02.2005 20:38:21] The log file used was "/var/tmp/testiso.11084.LOG" 
[09.02.2005 20:38:22] testiso ended on Wed Feb  9 20:38:22 MET 2005.
[09.02.2005 20:38:22] The RC is 0.
bash-2.05#

easycd.sh will first read the config file easycd.conf (if it exists in the current directory or in the home directory) and then, if called via an symbolic link, the config file <symbolic_link>.conf (if it exists in the current directory or in the home directory).

Next is a table with the different actions of easycd and what they do (parameter in brackets [] are optional):


action
symbolic link
parameter
what it does
comment
install [configfile]

name of the config file to write; default:  $HOME/easycd.conf
create the symbolic links in the current directory (if called as easycd.sh) and create the config file
use -O y to overwrite existing files and links
uninstall


remove symbolic links in the current directory
config files are not removed
createISOimg sourcedir [isofile] [volid]
copy_dir_to_iso_img
sourcedir is the directory tree for the ISO image
isofile is the name of the ISO file to create; default:  <sourcedir>.iso in the default output directory
volid is the Volume ID for the ISO image; default:  <sourcedir>
create an ISO image from a directory tree
only calls mkisofs
writecdrom sourcedir [volid]
easycd, easycd.sh
sourcedir is the directory with the files to write to CD
volid is the Volume ID for the CDROM; default: <sourcedir>
create an ISO image from the source directory and write it to a CDROM

writedvd sourcedir [volid]
easydvd
sourcedir is the directory with the files to write to DVD
volid is the Volume ID for the DVD; default: <sourcedir>
create an ISO image from the source directory and write it to a DVD
readcdrom isofile [srcdevice]
copy_cd_ot_iso_img
isofile is the name of the ISO file to write;
srcdevice is the device to read from; default: reader device
create an ISO image from a CDROM using dd

readdvd isofile [srcdevice]
copy_dvd_to_iso_img
isofile is the name of the ISO file to write;
srcdevice is the device to read from; default: reader device
create an ISO image from a DVD using dd

burncd isofile
cdrecord
isofile is the name of the ISO image
burn an ISO image to CD

burndvd isofile
dvdrecord
isofile is the name of the ISO image
burn an ISO image to DVD

clonecdrom [srcdevice]
clonecd
srcdevice is the device with the CD to copy; default: reader device copy a CDROM using readcd and cdrecord
If the CD contains many sectors that are unreadable by intention use
export READCD_OPTIONS=-nocorr before calling easycd.sh
clonedvd [sourcedevice]
clonedvd
srcdevice is the device with the DVD to copy; default: reader device copy a DVD using readcd and cdrecord
If the DVD contains many sectors that are unreadable by intention use
export READCD_OPTIONS=-nocorr before calling easycd.sh
copycdrom [srcdevice]
copycd
srcdevice is the device with the CD to copy; default: reader device copy a CDROM using dd and cdrecord

copydvd [srcdevice]
copydvd
srcdevice is the device with the DVD to copy; default: reader device
copy a DVD using dd and cdrecord

copyaudiocd [srcdevice] [useCDDB]
copyaudiocd
srcdevice is the device with the audio CD; default: reader device
read an audio CD using cdda2wav into WAV files and write them to a CD

readaudiocd [targetdir] [srcdevice] [useCDDB]
readaudiocd
targetdir is the directory for the temporary WAV files;  default is audio.$$ in the default output directory
srcdevice is the device with the Audio CD;  default is the reader device
useCDDB: if yes, use the CDDB to get the title of the CD; default is yes
read an audio CD using cdda2wav and write it to WAV files

writeaudiocd sourcedir [targetdevice]
writeaudiocd
sourcedir is the directory with the WAV files to write
targetdevice is the device used to write the CDROM; default: writer device
write an audio CD from WAV files created by readaudiocd

blankcdrom [blanktype]
blankcd
blanktype is the parameter for the blank command of cdrecord; default: fast
blank a CD
use cdrecord blank=help to get possible values for blankcd
blankdvd [blanktype]
blankdvd
blanktype is the parameter for the blank command of cdrecord; default: fast
blank a DVD
use dvdrecord blank=help to get possible values for blankcd
ejectcdrom [device]
ejectcd
device is the device to eject; default: writer device
eject a CD

ejectdvd [device]
ejectdvd
device is the device to eject; default: writer device eject a DVD

loadcdrom [device]
loadcd
device is the device to load; default: writer device load a CD into the device
loaddvd [device]
loaddvd
device is the device to load; default: writer device load a DVD into the device

testcd [device]
testcd
device is the device with the CD; default: writer device check all zip file and gz files on a CDROM
testdvd [device] testdvd
device is the device with the DVD; default: writer device check all zip file and gz files on a DVD

testiso [isofile]
testiso
isofile is the name of the file with the ISO image check all zip file and gz files in an ISO image
mounts the ISO image using lofiadm
listcd [device]

device is the device with the CD; default: writer device
list all files on a CDROM (ls -r)

listdvd [device]

device is the device with the DVD; default: writer device
list all files o a DVD (ls -r)

listiso isofile
isofile is the name of the file with the ISO image
list all files in an ISO image (ls -r)
mounts the ISO image using lofiadm



Back to top

Download


Download easycd.sh


Back to top