You are not logged in.
I have written a fairly capable script for my limited burning purposes. I haven't shared it because there are so many other solutions out there (including bashburn). Before I write up basic documentation for it and post it I thought I'd ask if anyone is interested. Below is a basic description.
Fact 1: I like cdrtools and not the wodim garbage. Fact 2: I am disappointed with all the GUI burning apps I've used - they are buggy and don't do what I want. So I wrote this script to integrate with my file manager for composing the burn and then using cdrecord, mkisofs, and growisofs to do the work. This way I could set all my speeds and options once in the script and be done with it.
For composing, this script will monitor a build folder you specify for changes, and keep reporting the current size of the contents, as well as creating MD5SUMS in the background as you add files. You use your file manager of choice to put files or links to files into this folder, thus creating your disc contents. Since I find most GUI burning apps are very lame when it comes to adding files, I prefer to use the file manager I'm used to for this, and it works great.
When it burns, it will include the MD5SUMS on the disc. It can also eject, reload, and check the integrity of discs against the build folder using either the MD5SUMS, or if these are missing, it will use compare (so you can check any disc or against an ISO).
This script will probably require some tweaking for your particular drive, desired speeds, etc., and you specify the drive at the top of the script.
Here is the usage:
bic --help
bic version 0.8.0
Usage: bic [OPTIONS] [SPEC]
Burns files/links in folder SPEC to CD or DVD
Burns isoimage SPEC to CD or DVD
OPTIONS
--size monitor SPEC folder size (Ctrl-C to quit)
--cd burn data to CDR [ 16x ]
--cdrw burn data to CDRW [ 4x ]
--dvd burn data to DVDR [ 4x ]
--dvdrw burn data to DVDRW [ 2x ]
--speed ## override default burn speed
-V VOLNAME volume name (32 max)
--copy copy disc (no SPEC)
(must also include burn option eg --cd )
--copykeep copy disc and keep ISO file SPEC
(can be used without burn)
--check check disc integrity
(optional SPEC to compare ISO or tree)
--snap write snapshot of disc contents to
/home/myuser/snapshots/
--snapfind SEARCHTEXT grep for SEARCHTEXT in
/home/myuser/snapshots/*
--reload reload tray
WARNING: RW discs are automatically overwritten!
Current Drive: /dev/scd0 (growisofs) aka /dev/sg3 (cdrecord)
I mainly would suggest this as a starting point for your own custom burn script, rather than a ready-made solution which will do everything you want OOTB. But I find it so much more flexible and reliable than GUI tools, owing its reliability to the well-made but politically blacklisted cdrtools. Any interest in this?
Last edited by IgnorantGuru (2010-06-22 19:46:53)
Offline
I'm interested in this as I agree with the points you made regarding GUI apps and like the filemanager approach. My bash-fu is rudimentary at best but I would like to tinker with this.
Thanks!
Hand over the spoon Milt...
Offline
Sure, I'll put it up in a day or so. Personally, I really like this approach. I was having so many problems with GUI apps, and after I wrote this it solved them all. It doesn't do everything (multi-session for example), but it won't take much to throw in any additional functions you want, and tweak the burning options to what you prefer. And the nice thing about scripts - once you get it working, it keeps working, in general.
Offline
You can use mybashburn as references for making your own script
Ask, and it shall be given you.
Seek, and ye shall find.
Knock, and it shall be opened unto you.
Offline
You can use mybashburn as references for making your own script
bashburn is a good reference. I didn't actually try it because I was looking to make a script that was simpler - just doing what I wanted, no more no less. bashburn looks like it does quite a bit, though.
Offline
Okay I have put up a page for "bic" with download link and basic documentation (I hate software without docs)...
http://igurublog.wordpress.com/downloads/script-bic/
See how that works for you. I also included instructions for installing the genuine cdrtools, which I think is worth doing.
Offline
Also, if you don't use hal, you may need to add "eject" as another dependency - forgot about that initially, but I have added it to the info page.
Last edited by IgnorantGuru (2010-06-23 01:15:03)
Offline
I have updated bic with a few features:
The ––size option is a bit smarter (notices changes to the folder even while calculating sums, and will ignore write-open files until they're closed). Also, a ––sizeonly option has been added which just monitors the size without calculating any sums.
A ––burn option has been added to auto-detect the media type.
A ––dvddl option has been added for burning to DVD Dual Layer discs. This is the same as a normal DVD burn except that it allows a different burn speed to be set in the user options.
Also, -iso-level 3 has been set for growisofs to accomodate files larger than 4GB.
For details visit
http://igurublog.wordpress.com/downloads/script-bic/
Offline
Just found this script, it's awesome, thanks. But it's not work with:
bic --burn /tmp/1
Detecting media...
Error: Unknown media type or detection failed
Tried: cdrecord dev=/dev/sr0 -media-info
but cdrecord dev=/dev/sr0 -media-info per se works all right, maybe it needs some update? And I'm using devmon, how to make devmon automount and bic check after burn work together?
Offline
Just found this script, it's awesome, thanks. But it's not work with:
bic --burn /tmp/1 Detecting media... Error: Unknown media type or detection failed Tried: cdrecord dev=/dev/sr0 -media-info
but cdrecord dev=/dev/sr0 -media-info per se works all right, maybe it needs some update?
Yes the bic on the site is a bit out of date. This code should work correctly with the latest cdrecord:
info=`cdrecord dev=$scsi -media-info 2> /dev/null`
if [ "$info" != "" ]; then
type=`echo "$info" | grep -m 1 "^Mounted media type:" | sed 's/Mounted media type: *\([A-Za-z\+\-]*\) *.*/\1/'`
status=`echo "$info" | grep -m 1 "^disk status:" | sed 's/disk status: *\(.*\)/\1/'`
fi
And I'm using devmon, how to make devmon automount and bic check after burn work together?
Here is my hacked version of bic that I've been using to burn BDRs, and it uses udevil to mount/unmount and should do the disc check correctly. You may need to modify for your purposes - bic is overdue for a rewrite! I would like to write it as a spacefm plugin. But maybe you can use this as a reference for now:
#!/bin/bash
# Script Name: bic http://igurublog.wordpress.com/downloads/script-bic/
# Requires: inotifywait sudo cdrtools dvd+rw-tools
# Recommended: autofs
# Note: For best results, the genuine cdrtools is recommended, not cdrkit
# http://cdrecord.berlios.de/private/linux-dist.html
# For non-root ISO mounting:
# http://igurublog.wordpress.com/downloads/script-mountiso/
# License: GNU GENERAL PUBLIC LICENSE Version 3 http://www.gnu.org/licenses/gpl-3.0.txt
# User Defaults
# Drive designation for growisofs - usually sr0 or scd0
# Note: /dev/scd0 may be a link to /dev/sr0
drive=/dev/sr0 #mod
# SCSI drive designation for cdrecord - usually sg2 or sg3
# Tip: make $scsi owned by root:optical and add your user to optical group
# Use "cdrecord -dev /dev/sg3 -checkdrive" to test if correct name
scsi=/dev/sr0 # was sg3
# Default burn speeds
cdrspeed=16
cdrwspeed=4
dvdrspeed=4
dvdrwspeed=2
dualspeed=2 # DVD-DL
bdrspeed=2
bdredlspeed=2
# Auto-mount folder for snapshots and checking (autofs?)
media=/media/dvd
# Temporary folder
tmp=/tmp/bic
# Snapshot folder
snapdir=~/snapshots
# ISO mount point
isomnt="/media/isomount" #mod
# Maximum disc capacities in 2K blocks
cdlimit=358400 # 700M in 2K blocks 700*512
dvdlimit=2291852 # 4475M #2288640 #4470M in 2K blocks 4470*512 #mod
duallimit=4167680 # 8140M in 2K blocks 8140*512
bdrlimit=12219392 # 23866M in 2K blocks = 23.3G
bdredllimit=24438784 # 47732M in 2K blocks = 46.6G
alert="" #mod
# End Of User Defaults
###############################################################################
help ()
{
cat << EOF
bic version 0.9.3-modified
Usage: bic [OPTIONS] [SPEC]
Burns files/links in folder SPEC to CD or DVD
Burns isoimage SPEC to CD or DVD
OPTIONS
--size monitor SPEC folder size and sums (Ctrl-C to quit)
--sizeonly --so monitor SPEC folder size (Ctrl-C to quit)
--burn burn to current media (auto-detected)
--cd --cdr burn to CDR [ ${cdrspeed}x ]
--cdrw burn to CDRW [ ${cdrwspeed}x ]
--dvd --dvdr burn to DVDR [ ${dvdrspeed}x ]
--dvdrw burn to DVDRW [ ${dvdrwspeed}x ]
--dvddl --dl burn to DVDR DL [ ${dualspeed}x ]
--bdr burn to BD-R [ ${bdrspeed}x ]
--bdredl burn to BD-RE-DL [ ${bdredlspeed}x ]
--speed ## override default burn speed
-V VOLNAME volume name (32 char max)
--copy copy disc (no SPEC)
(must also include burn option eg --burn or --cd)
--copykeep SPEC copy disc and keep ISO file SPEC
(can be used without burn)
--check [SPEC] check disc integrity
(optional SPEC to compare ISO or tree)
--snap write snapshot of disc contents to
$snapdir/
--snapfind SEARCHTEXT grep for SEARCHTEXT in
$snapdir/*
--reload reload tray
WARNING: RW discs are automatically overwritten!
Current Drive: $drive (growisofs) aka $scsi (cdrecord)
Instructions and updates:
http://igurublog.wordpress.com/downloads/script-bic/
EOF
exit
}
if [ "$1" = "" ]; then
help
fi
index=0
while [ "$1" != "" ];
do
if [ "${1:0:1}" = "-" ]; then
case "$1" in
--help | -help )
help
;;
--size )
size=1
sizesum=1
;;
--sizeonly | --so )
size=1
sizesum=0
;;
--burn )
burndetect=1
;;
--cdr | --cd )
cdr=1
defspeed=$cdrspeed
;;
--cdrw )
cdrw=1
defspeed=$cdrwspeed
;;
--dvd | --dvdr )
dvd=1
defspeed=$dvdrspeed
;;
--dvddl | --dl )
dvd=1
defspeed=$dualspeed
;;
--dvdrw )
dvdrw=1
defspeed=$dvdrwspeed
;;
--bdr )
bdr=1
defspeed=$bdrspeed
;;
--bdredl )
bdre=1
defspeed=$bdredlspeed
;;
--check )
check=1
;;
--copy )
copy=1
;;
--copykeep )
copykeep=1
;;
--snap )
snap=1
;;
--snapfind )
snapfind=1
if [ "$2" = "" ] || [ "${2:0:1}" = "-" ]; then
echo "Option $1 requires argument"
exit 1
fi
snapsearch="$2"
shift
;;
--reload )
reload=1
;;
--speed )
if [ "$2" = "" ] || [ "${2:0:1}" = "-" ]; then
echo "Option $1 requires argument"
exit 1
fi
speed="$2"
shift
;;
-V | -v )
if [ "$2" = "" ] || [ "${2:0:1}" = "-" ]; then
echo "Option $1 requires argument"
exit 1
fi
volname="$2"
test="${#volname}"
if (( test > 32 )); then
echo "Volume name too long - 32 max"
exit 1
fi
shift
;;
* )
echo "Unknown option $1"
exit
;;
esac
else
(( index += 1 ))
case $index in
1 )
tree="$1"
;;
* )
echo Too many arguments
exit 1
;;
esac
fi
shift
done
get_media_type()
{
type=""
status=""
info=`cdrecord dev=$scsi -media-info 2> /dev/null`
if [ "$info" != "" ]; then
type=`echo "$info" | grep -m 1 "^Mounted media type:" | sed 's/Mounted media type: *\([A-Za-z\+\-]*\) *.*/\1/'`
status=`echo "$info" | grep -m 1 "^disk status:" | sed 's/disk status: *\(.*\)/\1/'`
fi
}
#init
IFS=$'\n'
olddir=`pwd`
type=""
status=""
if (( burndetect == 1 )); then
if (( bdre + bdr + dvd + dvdrw + cdr + cdrw > 0 )); then
echo "Error: Option --burn cannot be used with other burn options"
exit 1
fi
echo "Detecting media..."
get_media_type
case "$type" in
CD-R | CD+R )
cdr=1
defspeed=$cdrspeed
;;
CD-RW | CD+RW )
cdrw=1
defspeed=$cdrwspeed
;;
DVD-R | DVD+R )
dvd=1
defspeed=$dvdrspeed
;;
DVD-RW | DVD+RW )
dvdrw=1
defspeed=$dvdrwspeed
;;
DVD-R/DL | DVD+R/DL )
dvd=1
defspeed=$dualspeed
;;
BD-R )
bdr=1
defspeed=$bdrspeed
;;
BD-RE ) # doesn't know DL ??
bdre=1
defspeed=$bdredlspeed
;;
* )
echo "Error: Unknown media type '$type' or detection failed"
echo " Tried: cdrecord dev=$scsi -media-info"
exit 2
;;
esac
echo " Media Type: $type ($status) [ Will burn at ${defspeed}x ]"
if [ "$status" != "empty" ]; then
if (( cdr + dvd + bdr != 0 )); then
echo "Error: Media is not blank and is not erasable"
exit 2
else
echo " NOTE: Media is NOT BLANK - will be OVERWRITTEN"
fi
fi
echo
fi
if [ "$speed" = "" ]; then
speed=$defspeed
fi
if [ "$volname" = "" ]; then
volname=`basename "$tree"`
fi
if (( bdre + bdr + dvd + dvdrw + cdr + cdrw > 0 )) && (( index < 1 )); then
echo "Error: Missing SPEC - must specify folder or ISO file to burn"
exit 1
fi
if (( bdre + bdr + dvd + dvdrw + cdr + cdrw + check + size + snap +snapfind > 1 )) || (( copy + copykeep > 1 )); then
echo "Too many options"
exit 1
fi
if (( copy == 1 )) && (( bdre + bdr + dvd + dvdrw + cdr + cdrw == 0 )); then
echo "Must specify burn option with copy (eg --dvd)"
exit 1
fi
# rm iso #mod
if (( bdre + bdr + dvd + dvdrw + cdr + cdrw > 0 )) && \
[ "$tree" != "$tmp/bic-temp.iso" ]; then
iso="$tmp/bic-temp.iso"
if [ -e "$iso" ]; then
echo
echo "TEMP ISO EXISTS"
x=5
while (( x > 0 )); do
echo "$x>>> rm -f \"$iso\""
sleep 1
(( x-- ))
done
echo ">>> rm -f \"$iso\""
rm -f "$iso"
fi
fi
mkdir -p "$tmp"
mkdir -p "$snapdir"
(( bdredllimitm = bdredllimit * 2048 / 1024 / 1024 ))
(( bdrlimitm = bdrlimit * 2048 / 1024 / 1024 ))
(( duallimitm = duallimit * 2048 / 1024 / 1024 ))
(( dvdlimitm = dvdlimit * 2048 / 1024 / 1024 ))
(( cdlimitm = cdlimit * 2048 / 1024 / 1024 ))
dircmp()
{
# Compare all files in $1\ (and subfolders) to $2\
# Symlinks are followed
diffcount=0
filecount=0
for f1 in `find -L "$1" -type f`;
do
f2="$2${f1#$1}"
(( filecount +=1 ))
if [ -e "$f2" ]; then
cmp -s "$f1" "$f2"
if [ $? != 0 ]; then
echo 'DIFFERS:' $f2
(( diffcount +=1 ))
fi
else
echo 'MISSING:' $f2
(( diffcount +=1 ))
fi
done
if (( filecount == 0 )); then
echo
echo 'ERROR: No files found.'
echo
return 2
elif (( diffcount == 0 )); then
echo
echo 'All '$filecount' files are equal.'
echo
return 0
else
echo
echo 'WARNING: '$diffcount' of '$filecount' files differ.'
echo
return 1
fi
}
mediapause()
{
mediatries=30
x=0
echo "Waiting for media mount"
sleep 4
while (( x < mediatries )); do
udevil mount /dev/sr0 #mod
echo -n "."
cd "$media" 2> /dev/null # with autofs this should trigger mount
sleep 3
test=`find "$media/" -maxdepth 1 -mindepth 1 2> /dev/null`
if [ "$test" != "" ]; then
break
fi
(( x += 1 ))
done
echo
if (( x == mediatries )); then
echo "ERROR: media $media is not mounted"
cd "$olddir"
exit 2
fi
cd "$media"
}
mkmd5() # $1=size if not final; returns 1 if no new sums were created
{
unset md5_old
unset md5_old_sum
oldx=0
nonew=1
echo "Scanning sums..."
cd "$tree"
# read old sums
if [ -e "$tree/.checksum.md5.gz" ]; then
cat "$tree/.checksum.md5.gz" | gzip -d > "$tmp/.checksum.md5-old.tmp"
else
rm -f "$tmp/.checksum.md5-old.tmp"
fi
for f in "$tmp/.checksum.md5-old.tmp" "$tmp/.checksum.md5.tmp"; do
if [ -s "$f" ]; then
for l in `cat -E "$f"`; do
l="${l%\$}"
lsum="${l%% *}"
lname="${l#* }"
if [ ${#lsum} -eq 32 ] && [ "$lname" != "" ]; then
md5_old[$oldx]="$lname"
md5_old_sum[$oldx]="$lsum"
(( oldx++ ))
fi
done
fi
done
rm -f "$tmp/.checksum.md5.tmp"
# get list of files in use
inuse=`lsof -w -F an -x +D "$tree" 2>/dev/null`
# get and parse file list
flist=`find -L -type f`
if [ "$flist" != "" ]; then
for f in $flist; do
f="${f#./}"
if [ ! -r "$f" ]; then
echo "Warning: Permission denied: $tree/$f"
elif [ "$f" != ".checksum.md5.gz" ]; then
# file is currently open for write?
open_write=0
if [ "$inuse" != "" ]; then
awline=0
for fu in $inuse; do
if [ "$fu" = "aw" ]; then
awline=1
elif [ "${fu:0:1}" = "n" ] && (( awline == 1 )); then
if [ "n$tree/$f" = "$fu" ]; then
open_write=1
break
fi
awline=0
else
awline=0
fi
done
fi
if (( open_write == 1 )) && [ "$1" != "size" ]; then
echo "WARNING: $tree/$f is write-opened (may produce bad md5sum)"
open_write=0
fi
if (( open_write == 1 )); then
echo "Ignoring write-open file $tree/$f"
else
# have old md5?
x=0
have_it=0
while [ "${md5_old[$x]}" != "" ]; do
if [ "${md5_old[$x]}" == "$f" ]; then
# reuse old md5
echo "${md5_old_sum[$x]} $f" >> "$tmp/.checksum.md5.tmp"
have_it=1
break
fi
(( x++ ))
done
if (( have_it == 0 )); then
# new md5
echo "md5sum \"$f\""
md5sum "$f" >> "$tmp/.checksum.md5.tmp"
# update list of files in use
inuse=`lsof -w -F an -x +D "$tree" 2>/dev/null`
nonew=0
fi
fi
fi
done
fi
unset md5_old md5_old_sum
unset inuse flist
cd "$olddir"
rm -f "$tree/.checksum.md5.gz"
if [ -e "$tmp/.checksum.md5.tmp" ]; then
cat "$tmp/.checksum.md5.tmp" | gzip > "$tree/.checksum.md5.gz"
fi
rm -f "$tmp/.checksum.md5.tmp"
rm -f "$tmp/.checksum.md5-old.tmp"
return $nonew
}
checkdisc()
{
mediapause
if [ -d "$tree" ]; then
# dircmp
echo "Checking by dir compare..."
dircmp "$tree" "$media"
if [ $? != 0 ]; then
#udevil umount /dev/sr0 #mod
cd "$olddir"
echo
echo "! ! ! BAD COMPARE ! ! !"
exit 2
fi
else
# md5 check
echo "Checking MD5..."
if [ -e "$media/.checksum.md5" ]; then
md5sum -c --warn --quiet "$media/.checksum.md5"
elif [ -e "$media/.checksum.md5.gz" ]; then
cat "$media/.checksum.md5.gz" | gzip -d | md5sum -c --warn --quiet
else
#udevil umount /dev/sr0 #mod
cd "$olddir"
echo
echo "ERROR: $media/.checksum.md5* not found"
exit 2
fi
if [ $? != 0 ]; then
#udevil umount /dev/sr0 #mod
cd "$olddir"
echo
echo "! ! ! BAD CHECKSUMS ! ! !"
if [ "$alert" != "" ]; then
eval $alert #mod
fi
exit 2
fi
fi
#udevil umount /dev/sr0 #mod
echo
echo "Checked OK"
cd "$olddir"
if [ "$alert" != "" ]; then
eval $alert #mod
fi
}
checkiso()
{
echo "Mount ISO for check..."
# Is mountiso available?
mntcmd=""
for testcmd in mountiso /usr/bin/mountiso /opt/scripts/mountiso; do
test=`$testcmd --help 2> /dev/null | grep "igurublog.wordpress.com"`
if [ "$test" != "" ]; then
mntcmd="$testcmd"
break
fi
done
# something already mounted on mountiso mountpoint?
if [ "$mntcmd" != "" ]; then
test=`$testcmd --help | grep "# unmounts " | sed 's/.* # unmounts \(.*\)/\1/'`
if [ "$test" = "" ]; then
#echo "could not determine mountiso mount point - using sudo mount"
mntcmd=""
else
mntpt="$test"
test=`mount | grep " [a-z]* $mntpt "`
if [ "$test" != "" ]; then
#echo "mountiso already mounted - using sudo mount"
mntcmd=""
mntpt=""
fi
fi
#else
#echo "mountiso not available - using sudo mount"
fi
mntcmd="udevil mount" #mod
# Is mountiso configured?
#if [ "$mntcmd" != "" ]; then
# test=`$mntcmd 2>&1 | grep "system is not setup for non-root user"`
# if [ "$test" != "" ]; then
# #echo "mountiso not configured - using sudo mount"
# mntcmd=""
# fi
# fi
if [ "$mntcmd" != "" ]; then
# mount using mountiso
eval $mntcmd $tree "$isomnt"
mntpt="$isomnt"
else
# mount using sudo mount
mntpt="$isomnt"
sudo mkdir -p "$isomnt"
sudo chmod ugo+rwx "$isomnt"
sudo mount -t iso9660 -o loop,ro "$tree" "$isomnt"
fi
test=`mount | grep " [a-z]* $mntpt "`
if [ "$test" = "" ]; then
echo "ISO mount failed"
exit 2
fi
mediapause
echo "Checking..."
dircmp "$mntpt" "$media"
errnum=$?
cd "$olddir"
if [ "$mntcmd" = "" ]; then
sudo umount "$isomnt"
sudo rmdir "$isomnt"
else
#$mntcmd
udevil umount "$isomnt" #mod
fi
if [ $errnum != 0 ]; then
echo
echo "! ! ! BAD COMPARE ! ! !"
fi
if [ "$alert" != "" ]; then
eval $alert #mod
fi
return $errnum
}
mksnap()
{
mediapause
volid=`isoinfo dev=$drive -d 2> /dev/null | grep "^Volume id: "`
volid="${volid#Volume id: }"
if [ "$volid" != "" ]; then
msg="Write snapshot of $volid ? (Enter=Yes; n=No; or custom name)"
else
msg="Write snapshot? (Enter=No; n=No; or custom name)"
fi
echo
echo "$msg"
read s1
if [ "$s1" = "n" ] || [ "$volid$s1" = "" ]; then
cd "$olddir"
udevil umount /dev/sr0 #mod
return
else
if [ "$s1" != "" ]; then
volid="$s1"
fi
get_media_type
if [ "$type" != "" ]; then
type="$type "
fi
if [ -e "$media/.checksum.md5.gz" ]; then
media_date=`stat -c %y "$media/.checksum.md5.gz"`
media_date="${media_date%% *}"
else
echo "WARNING: .checksum.md5.gz not found" 1>&2
media_date="$(date "+%Y-%m-%d")"
fi
echo "SNAPSHOT: $volid" > "$snapdir/$volid"
echo " $type$media_date" >> "$snapdir/$volid"
echo >> "$snapdir/$volid"
cd "$media"
echo "---------------------------------------"
/bin/ls -1RshpAv >> "$snapdir/$volid"
echo "SNAPSHOT: $volid"
echo " $type$media_date"
echo
/bin/ls -1RshpAv | head -n 20
echo "..."
echo "---------------------------------------"
#/bin/ls -hogRp --time-style="+%Y-%m-%d" "$media/" | awk ' BEGIN{FS=" ";} {if ( $5 != "" ) {$1=$4; $2=$3"\t"; $3=$5; $4=""; $5=""}; print}' >> "$snapdir/$volid"
fi
cd "$olddir"
udevil umount /dev/sr0 #mod
}
# reload
if (( reload == 1 )); then
eject -r $drive
sleep 3
eject -t $drive
if (( copy + check == 0 )) && [ "$tree" = "" ]; then
exit 3
fi
fi
# check
if (( check == 1 )); then
if [ "$tree" = "" ] || [ -d "$tree" ]; then
checkdisc
elif [ -e "$tree" ] && [ "$tree" != "" ]; then
checkiso
else
echo "Invalid check SPEC: $tree"
fi
exit 2
fi
# snap
if (( snap == 1 )); then
mksnap
exit
fi
# snapfind
if (( snapfind == 1 )); then
grep -iR "$snapsearch" "$snapdir/"
exit
fi
# copy
if (( copy == 1 )) || (( copykeep == 1 )); then
if (( copykeep == 1 )); then
if [ "$tree" = "" ]; then
echo "Must add ISO SPEC with copykeep"
exit 1
elif [ -e "$tree" ]; then
echo "ISO image already exists: $tree"
exit 1
fi
iso="$tree"
echo "Keeping custom ISO Image $iso"
else
if [ "$tree" != "" ]; then
echo "Too many arguments - use no SPEC with copy"
exit 1
fi
iso="$tmp/bic-temp.iso"
rm -f "$iso"
fi
echo "Reading disc..."
dd if=$drive of="$iso"
if [ $? != 0 ] || [ ! -e "$iso" ]; then
echo "ERROR: Disc image not copied"
rm -f "$iso"
exit 4
elif (( bdr + dvd + dvdrw + cdr + cdrw != 0 )); then
tree="$iso"
echo
sleep 1
echo "Please insert new disc to burn:"
eject -r $drive
read s1
eject -t $drive
sleep 3
# passes down to burning
fi
fi
# check $tree
if [ ! -e "$tree" ]; then
echo "File not found: $tree"
exit 1
fi
# size
if (( size == 1 )); then
if [ ! -d "$tree" ]; then
echo "Cannot run size on isoimage spec - specify folder"
exit 1
fi
while [ -d "$tree" ]; do
bytes=`du -sbL "$tree"`
bytes="${bytes%%[[:blank:]]*}"
(( bytes = bytes / 1024 / 1024 ))
dispsize="$bytes MB"
if (( sizesum == 1 )); then
echo "$dispsize ..."
while ( mkmd5 size ); do
bytes=""
done
bytes=`du -sbL "$tree"`
bytes="${bytes%%[[:blank:]]*}"
(( bytes = bytes / 1024 / 1024 ))
dispsize="$bytes MB"
fi
dsize=`du -sL --block-size=2048 "$tree"`
dsize="${dsize%%[[:blank:]]*}"
#echo "dsize=$dsize"
if (( dsize > bdredllimit )); then
(( bysize = (dsize - bdredllimit)*2048/(1024*1024) ))
sizemsg="( exceeds ${bdredllimitm}M BD-RE-DL by ${bysize} MB )"
elif (( dsize > bdrlimit )); then
(( remsize = (bdredllimit - dsize)*2048/(1024*1024) ))
(( bysize = (dsize - bdrlimit)*2048/(1024*1024) ))
sizemsg="( exceeds ${bdrlimitm} MB BD-R by ${bysize} MB + ${remsize} MB remaining on BD-RE-DL )"
elif (( dsize > duallimit )); then
(( remsize = (bdrlimit - dsize)*2048/(1024*1024) ))
(( bysize = (dsize - duallimit)*2048/(1024*1024) ))
sizemsg="( exceeds ${duallimitm} MB DVD-DL by ${bysize} MB + ${remsize} MB remaining on BD-R )"
elif (( dsize > dvdlimit )); then
(( remsize = (duallimit - dsize)*2048/(1024*1024) ))
(( bysize = (dsize - dvdlimit)*2048/(1024*1024) ))
sizemsg="( exceeds ${dvdlimitm} MB DVD by ${bysize} MB + ${remsize} MB remaining on DVD-DL )"
elif (( dsize > cdlimit )); then
(( remsize = (dvdlimit - dsize)*2048/(1024*1024) ))
(( bysize = (dsize - cdlimit)*2048/(1024*1024) ))
sizemsg="( exceeds ${cdlimitm} MB CD by ${bysize} MB + ${remsize} MB remaining on DVD )"
else
(( remsize = (cdlimit - dsize)*2048/(1024*1024) ))
sizemsg="( ${remsize}M remaining on CD )"
fi
echo "$dispsize $sizemsg"
nochange=1
while (( nochange )); do
changes=`inotifywait -rq -e create -e close_write -e move -e delete "$tree"`
#echo "$changes"
nochange=0
for c in $changes; do
if [[ "$c" =~ (.*)[[:space:]]CREATE[[:space:]](.*) ]]; then
if [ -e "${BASH_REMATCH[1]}${BASH_REMATCH[2]}" ]; then
if [ ! -h "${BASH_REMATCH[1]}${BASH_REMATCH[2]}" ]; then
# a non-link file has been created so ignore all until its closed
# this gives time for copy of large file to complete before
# md5sum is calculated
#echo "ignore create ${BASH_REMATCH[1]}${BASH_REMATCH[2]}"
nochange=1
break
fi
fi
fi
done
done
done
exit
fi
# dvd bd
if (( dvd == 1 )) || (( dvdrw == 1 )) || (( bdr == 1 )) || (( bdre == 1 )); then
# folder or iso?
if [ ! -d "$tree" ]; then
# custom iso
iso="$tree"
echo "Using custom ISO Image $iso"
customiso=1
# burn
#growisofs -speed=$speed -Z $drive "$iso" # does not work for dd iso
cdrecord -v dev=$scsi speed=$speed -fs=8m -data "$iso"
else
# burn
customiso=0
mkmd5
du -sL --block-size=2048 "$tree"
iso="$tmp/bic-temp.iso"
if [ -e "$iso" ]; then
echo
echo "TEMP ISO EXISTS"
x=5
while (( x > 0 )); do
echo "$x>>> rm -f \"$iso\""
sleep 1
(( x-- ))
done
echo ">>> rm -f \"$iso\""
rm -f "$iso"
fi
mkisofs -fRrJl --iso-level 3 -joliet-long -allow-multidot -allow-leading-dots -V "$volname" -o "$iso" "$tree"
if [ $? -ne 0 ]; then
exit 2
fi
cdrecord -v speed=$speed -fs=8m -dev=/dev/sr0 -dao "$iso"
# use env in case user is running as non-root sudo
#env -u SUDO_COMMAND MKISOFS=/usr/bin/mkisofs growisofs -speed=$speed -Z $drive -r -J -joliet-long -iso-level 3 -f -allow-multidot -allow-leading-dots -l -pad -dvd-compat -udf -V "$volname" "$tree"
fi
# check and snap
if [ $? = 0 ]; then
sleep 6
echo
eject -r $drive
if [ $? -ne 0 ]; then
echo
echo "WARNING: No check performed due to apparent error"
if (( copy == 1 )); then
echo "ISO retained: $iso"
fi
exit 2
fi
sleep 3
eject -t $drive
sleep 6
if (( customiso == 0 )); then
checkdisc # may exit
mksnap
else
checkiso
errnum=$?
if (( copy == 1 )); then
if [ $errnum = 0 ]; then
rm -f "$iso"
else
echo "Check failed so ISO retained: $iso"
fi
fi
fi
else
echo
echo "WARNING: No check performed due to apparent error"
if (( copy == 1 )); then
echo "ISO retained: $iso"
fi
exit 2
fi
exit
fi
# cd
if (( cdr == 1 )) || (( cdrw == 1 )); then
# folder or iso?
if [ ! -d "$tree" ]; then
# custom iso
iso="$tree"
echo "Using custom ISO Image $iso"
customiso=1
else
# make iso
iso="$tmp/bic-temp.iso"
rm -f "$iso"
customiso=0
mkmd5
du -sL --block-size=2048 "$tree"
mkisofs -r -J -joliet-long -l -f -pad -allow-multidot -allow-leading-dots -V "$volname" -o "$iso" "$tree"
if [ $? != 0 ] || [ ! -e "$iso" ]; then
echo
echo "ERROR: ISO creation error"
rm -f "$iso"
exit 5
fi
fi
if (( cdrw == 1 )); then
blank="blank=fast"
else
blank=""
fi
# burn
cdrecord -v dev=$scsi speed=$speed $blank -data "$iso"
errnum=$?
if (( customiso == 0 )); then
rm -f "$iso"
fi
# check and snap
if [ $errnum = 0 ]; then
sleep 2
echo
eject -r $drive
if [ $? -ne 0 ]; then
echo
echo "WARNING: No check performed due to apparent error"
if (( copy == 1 )); then
echo "ISO retained: $iso"
fi
exit 2
fi
sleep 3
eject -t $drive
sleep 3
if (( customiso == 0 )); then
checkdisc # may exit
mksnap
else
checkiso
errnum=$?
if (( copy == 1 )); then
if [ $errnum = 0 ]; then
rm -f "$iso"
else
echo "Check failed so ISO retained: $iso"
fi
fi
fi
else
echo
echo "WARNING: No check performed due to apparent error"
if (( copy == 1 )); then
echo "ISO retained: $iso"
fi
exit 2
fi
exit
fi
# ChangeLog:
# 0.9.3: --size shows space remaining
# 0.9.2: added non-root mountiso support
# adjusted wait for mount timing
# 0.9.1: fixed erroneous write-open warning
# added --burn option
# 0.9.0: mkmd5 ignores or warns about write-open files
# added --dvd-dl custom burn speed
# added -iso-level 3 to growisofs command for file > 4GB
# 0.8.2: improved mediapause; mkmd5 detects permission denied;
# growisofs sudo fix for non-root sudo use
# 0.8.1: added -F to md5sum grep to handle regex characters more cleanly
Offline
I am kinda newby in scripts... I tried to use hacked version, it burned a dvd but can't check it. After writing disk bic says
umount: /media/DVD: umount failed: Операция не позволяется
eject: unmount of `/media/DVD' failed
WARNING: No check performed due to apparent error
If I eject disk manually then load it again it mounts by devmon to /media/<volumename> but bic can't see it. I tried:
bic --check ~/tmp/2003/
Waiting for media mount
udevil: /dev/sr0 прописан в fstab - выполнение mount от текущего пользователя
mount: can't find /dev/sr0 in /etc/fstab
.udevil: /dev/sr0 прописан в fstab - выполнение mount от текущего пользователя
mount: can't find /dev/sr0 in /etc/fstab
.udevil: /dev/sr0 прописан в fstab - выполнение mount от текущего пользователя
mount: can't find /dev/sr0 in /etc/fstab
.^C
And it's rolling until I Сtrl-С'd
If I change "media=" in bic file to "/media/2003/" then check works.
Offline
You can change the udevil mount commands in the script to
udevil mount /dev/sr0 "$media"
The reason I don't need this is I have this line in fstab:
/dev/sr0 /media/dvd auto ro,user,noauto,unhide 0 0
Offline
I added
/dev/sr0 /media/dvd auto ro,user,noauto,unhide 0 0
to fstab, and changed in bic file
media=/media/DVD/
to
media=/media/dvd/
just in case , now it burns and checks. Thanks a lot.
Another request: is there a way not to write .checksum.md5.gz file on disk? Especially for DVD-Video, it's kinda break specification I guess
Offline
Another request: is there a way not to write .checksum.md5.gz file on disk? Especially for DVD-Video, it's kinda break specification I guess
That is automatic at present, but you could either hack it out or add a switch if it really breaks anything. That file enables you to always check the disc later even if the original files are gone... (no dir spec needed)
bic --check
Offline