keep in mind...this took about 3 days to write (not straight)
and it's just a part of the utility i'm currently working on
but since it works great for ripping a disk stand alone
i'm setting it free into the wild...and plan to add it as a function
in my cd burning script (the prementioned work in progress)
NOTE: This script will not burn an ISO...just create one from an existing cd
this script can take either no arguments...or one of the two...or both
best thing to do is just take it home and play with it
and here it is...
Code:
#!/bin/bash
# Author: Joshua Bailey
# Script: makeISO
# Syntax: makeISO /dev/cdrom /home/$USER/newOS.iso
# Summary: This script takes a cd-rom in the drive
# you specify and creates an iso image
# that you can distribute and/or burn
# yourself
((n=0))
function notAForwardSlash
{
if [[ $1 != '/' ]]
then
return 0
else
return 1
fi
}
function getFile
{
STRING=$1
LENGTH=${#STRING}
n=0
for ((n=0;n <= $LENGTH; n++))
do
CHAR=${STRING:$n:1}
if notAForwardSlash $CHAR
then
FileName=$FileName$CHAR
else
FileName=""
fi
done
}
function getPath
{
getFile $1
newPath=${1:0:(${#1}-${#FileName})}
}
function getDevice
{
read -p "Please input the device name (/dev/cdrom): " DEV
if [[ $DEV = "" ]]
then
DEV=/dev/cdrom
fi
}
function getFileName
{
read -p "Please state the path for the ISO (/home/$USER/newOS.iso): " fISO
if [[ $fISO = "" ]]
then
fISO=/home/$USER/newOS.iso
fi
}
numArgs=$#
while [[ $n != 1 ]]
do
if [[ $numArgs > 1 ]]
then
if [[ `echo $1 | grep /dev` ]]
then
DEV=$1
elif [[ `echo $1 | grep .iso` ]]
then
fISO=$1
elif [[ `echo $2 | grep /dev` ]]
then
DEV=$2
elif [[ `echo $2 | grep .iso` ]]
then
fISO=$2
fi
else
if [[ $numArgs -eq 1 ]]
then
if [[ `echo $1 | grep /dev` ]]
then
DEV=$1
getFileName
else
fISO=$1
getDevice
fi
else
getDevice
getFileName
fi
fi
getPath $fISO
while [[ ! -d $newPath ]]
do
echo "$newPath does not exist!"
read -p "Would you like me to create it? (y/n) " ans
ans=`echo $ans | tr :upper: :lower:`
ans=${ans:0:1}
if [[ $ans != "n" ]]
then
mkdir $newPath
else
getFileName
fi
getPath $fISO
done
echo "About to create $fISO from disk in $DEV"
read -p "Is this correct? (y/n)" ans
ans=`echo $ans | tr :upper: :lower:`
ans=${ans:0:1}
if [[ $ans != "n" ]]
then
echo "*** making iso ***"
umount $DEV > /dev/null
dd if=$DEV of=$fISO bs=32k
if [[ $? != 0 ]]
then
echo "*** Error ***"
read -p "Would you like to try again? (y/n) " ans
ans=`echo $ans | tr :upper: :lower:`
ans=${ans:0:1}
if [[ $ans != "y" ]]
then
echo "*** exiting ***"
eject
exit
fi
else
echo "*** iso created ***"
echo "*** located at:$fISO ***"
# forgot this part in the first post
# it ends the loop and asks if you want
# to make another iso
read -p "Would you like to create another? (y/n) " ans
ans=`echo $ans | tr :upper: :lower:`
ans=${ans:0:1}
if [[ $ans != "y" ]]
then
n=1
else
n=0
DEV=""
fISO=""
fi
fi
else
read -p "Would you like to try again? (y/n)" ans
ans=`echo $ans | tr :upper: :lower:`
ans=${ans:0:1}
if [[ $ans != "y" ]]
then
echo "*** exiting ***"
eject
exit
else
echo "*** trying again ***"
numArgs=0
fi
fi
done
eject
please please please
give me feed back on this script
i'd like to know what you think i should add or subtract from this portion
all ideas are very much appreciated