#! /bin/bash ############################################################################### # Settings for menu choices... ############################################################################### INFOCD=1 WIPECD=1 LSTIMG=1 CHANGE=1 DELETE=1 TESTCD=1 CONFIG=1 HOTCNF=":" QUITSEP="---------------------" QUITDSC=": Quit this program." #------------------------------------------------------------------------------ # NOTES: Some of the options are automatic, the rest are enabled/disabled here. #------------------------------------------------------------------------------ # ?????? HELP appears automatically if the help file exists and is readable. # INFOCD determines whether users can get information about a CD in drive. # WIPECD determines whether users can erase a re-writable disk from menu. # ?????? READ appears if there are any defined read drives. # To eliminate READ, undefine CDRx or NAMx for ALL x in 1-9 and a-z. # LSTIMG determines whether users can list available CD images using menu. # CHANGE determines whether users can edit CD layout files from menu. # DELETE determines whether users can delete CD files from menu. # ?????? WRITE appears if there are any defined write drives. # To eliminate WRITE, undefine CDWx or NAMx for ALL x in 1-9 and a-z. # TESTCD determines whether users can test/verify a CD against an image file. # CONFIG determines whether users can get into the setup menu from main menu. # HOTCNF defines extra hotkey for the setup menu; in case it's disabled. # OTHKEYx defines extra menu commands (up to 15 -- use 1-9 and A-F for x). # OTHDSCx are the menu descriptions for the 15 extra command keys (With ": "). # OTHCMDx are the extra commands. "%k" is for the key pressed, "%." for a "%". # You can add plain text between the options using OTHDSCx without OTHKEYx. # Commands can begin with QUERY: to ask Yes/No before executing command. # Begin with PAUSE: or ERROR: for pausing [always / error] after execution. # QUERY: must be first if also using either PAUSE: OR ERROR:. # QUITSEP is the separator line that prints between the other options and quit. # QUITDSC is the description for quit command, blanking it will hide option. ############################################################################### ############################################################################### # Settings for screen colors... ############################################################################### C0="\e[0m" CT="\e[1;33;41m" CL="\e[0;1;31m" CM="\e[0;1;33m" CC="\e[1;33;44m" CB="\e[1;37;44m" CE="\a\e[1;5;34;43m" #------------------------------------------------------------------------------ # C0=Normal color - background of screen, etc. # CT=Title at top of screen # CL=List color (CDs and drives) # CM=Menu color for text in menu # CC=Color of choice key in menu list # CB=Bold color # CE=Error message color #------------------------------------------------------------------------------ # ANSI Colors: 0=Normal;1=Bright;3x=Foreground color;4x=Background color # Where x in 3x and 4x above specifies the color. # Colors are 0=Black;1=Red;2=Green;3=Yellow;4=Blue;5=Magenta;6=Cyan;7=White # As a rule, add a 0 at the beginning when there's no background color (4x) # Use 1 (for bright) for most colors other than white # Color sequences start with "\e[" and end with "m"; separate numbers by ; # You can also \a for AlarmBell, \t for Tab, etc. See bash docs for more. ############################################################################### ############################################################################### # Settings for automatic drive selections... ############################################################################### CD_I="" CD_E="" CD_R="" CD_W="" CD_T="" #------------------------------------------------------------------------------ # CD_I Defines which drive to use to get disk info, blank = "ask user". # CD_E Defines which drive to use to erase, blank = "ask user". # CD_R Defines which drive to use to read, blank = "ask user". # CD_W Defines which drive to use to write, blank = "ask user". # CD_T Defines which drive to use to test disks, blank = "ask user". ############################################################################### ############################################################################### # Settings for program options... ############################################################################### AUTOHELP=".cds.auto.help" AUTOSHOW=1 ALLDEV=1 WARNTIME=81 IOPTS="" EOPTS="" ROPTS="--read-raw" WOPTS="-n --overburn --eject" TOPTS="--read-raw" #------------------------------------------------------------------------------ # AUTOHELP file is displayed at the start of each program run if found. # AUTOSHOW determines whether image files are always listed at top of menu. # ALLDEV determines whether multiple device names are shown in write choices. # WARNTIME number of minutes of free disk space below which a WARNING occurs. # IOPTS is added to info commands on all drives. # EOPTS is added to erase commands for re-writable disks on all drives. # ROPTS is added to read commands on all drives. # WOPTS is added to write commands on all drives. # TOPTS is added to read commands when verifying a disk on all drives. # NOTES: The read/write options can also be defined by drive selection menu: # IOPx is for defining additional (after IOPTS) options for info command. # EOPx is for defining additional (after EOPTS) options for erase command. # ROPx is for defining additional (after ROPTS) options for read command. # WOPx is for defining additional (after WOPTS) options for write command. # TOPx is for defining additional (after TOPTS) options when verifying. # i.e. Setting "WOP4=xxx" adds xxx after WOPTS value when writing choice 4. # YES it WOULD be nice to have options for each drive... in Version 2. ############################################################################### ############################################################################### # Settings for externally used commands and disk read/write commands... ############################################################################### CLEAR="clear" SLEEP="read -r -s -n 1 -t 3 junk" PAUSE="read -r -s -n 1 junk" EDIT="vi" VIEW="less" INFOCMD="cdrdao disk-info --driver generic-mmc-raw --device" WIPECMD="cdrdao blank --blank-mode minimal --device" READCMD="cdrdao read-cd --driver generic-mmc-raw --device" WRITECMD="cdrdao write --driver generic-mmc-raw --device" VERICMD="cdrdao read-cd --driver generic-mmc-raw --device" LISTDEV="cdrdao scanbus" DIFFCMD="diff -s -q" #------------------------------------------------------------------------------ # CLEAR is used to clear the screen at the start of each menu. # SLEEP is used to pause briefly when displaying non-essential messages. # PAUSE is used after "Deleted" and similar status messages. # EDIT is used to edit layouts and configuration files. # VIEW is used to view lists and the help file (must accept piped input). # INFOCMD, WIPECMD, READCMD, WRITECMD, VERICMD, and LISTDEV are disk commands. # DIFFCMD is used when verifying disks against image file--takes 2 file params. ############################################################################### ############################################################################### # Settings for data/running directories, default locations, and file names. # These settings are used in the code here and should not be changed. ############################################################################### CFGEXT="conf" HLPEXT="help" DEFDIR="/usr/bin/" HOMDEF="/" DATDIR="CDImages" #------------------------------------------------------------------------------ # CFGEXT is the default config file extension. # HLPEXT is the default help file extension (auto help file only). # The DEFDIR (or more likely the path where the command is found) is used as a # default location for the help and setup files. Generally, all program # files go in the same directory; $0 is passed by the OS to indicate where # they are located. Since some OSs don't pass this info, the DEFDIR is used # to find the help and configuration files only on those systems. It is # ignored on most systems. You may put CD Burner and its files anywhere. # DEFDIR is only used when $0 doesn't contain the full path to executable. # HOMDEF is default HOME dir - NOT USED unless $HOME is blank (must end in /). # The DATDIR is where the CD files are stored relative to $HOME (or $HOMDEF). # These directory variables are used in the sections below to find other files. ############################################################################### ############################################################################### # Calculating program directory and name for future use. ############################################################################### PD=`echo "$0" | sed "s/[^\\/]*$//"` if [ ".$PD" == "." ] ; then PD="$DEFDIR" PP="$DEFDIR$0" elif [ ".$PD" == "../" ] ; then PD=`pwd`;PD="${PD//%\//}/" PP="$PD${0:2}" else PP="$0" fi PN=`echo "$0" | sed "s/^.*\\///"` #------------------------------------------------------------------------------ # PD, the program directory, is where standard files are located -- help, etc # PP is full path used to set the filenames for help and config files below. # PN is the program basename (without directory prefix) for related filenames. ############################################################################### ############################################################################### # Settings for setup and help files... ############################################################################### HELP="$PN.$HLPEXT" CONF="$PN.$CFGEXT" if [ ! -r "$HELP" -a -r "$PP.$HLPEXT" ] ; then HELP="$PP.$HLPEXT" fi if [ ! -r "$CONF" -a -r "$PP.$CFGEXT" ] ; then CONF="$PP.$CFGEXT" fi #------------------------------------------------------------------------------ # HELP is the file showed by the help key. # CONF is the setup file. If value changed, will run the new file next [...] # WARNING: The CONF file is executed in full program context. Pay detailed # attention to security issues this entails if you allow users to config. ############################################################################### ############################################################################### # Setting for main directory, where images are stored. ############################################################################### if [ ".$HOME" == "." ] ; then CD="$HOMDEF$DATDIR" else CD="${HOME//%\//}/$DATDIR" fi #------------------------------------------------------------------------------ # The CD is where the program will change to and is where the disk files exist. ############################################################################### ############################################################################### # Settings for device names. ############################################################################### CDR1="ATA:0,0,0" CDW1="$CDR1" NAM1="ATA Primary Master (usually hard drive)" CDR2="ATA:0,1,0" CDW2="$CDR2" NAM2="ATA Primary Slave (sometimes CD/DVD location)" CDR3="ATA:1,0,0" CDW3="$CDR3" NAM3="ATA Secondary Master (usual CD/DVD location)" CDR4="ATA:1,1,0" CDW4="$CDR4" NAM4="ATA Secondary Slave (sometimes CD/DVD location)" CDR5="ATA:2,0,0" CDW5="$CDR5" NAM5="SATA or expansion card IDE drive 1 location" CDR6="ATA:3,0,0" CDW6="$CDR6" NAM6="SATA or expansion card IDE drive 2 location" CDR7="0,0,0" CDW7="$CDR7" NAM7="1st USB/SCSI drive" CDR8="1,0,0" CDW8="$CDR8" NAM8="2nd USB/SCSI drive" CDR9="2,0,0" CDW9="$CDR9" NAM9="3rd USB/SCSI drive" CDRa="3,0,0" CDWa="$CDRa" NAMa="4th USB/SCSI drive" CDRb="4,0,0" CDWb="$CDRb" NAMb="5th USB/SCSI drive" CDRc="5,0,0" CDWc="$CDRc" NAMc="6th USB/SCSI drive" CDRz="" CDWz="$CDW1 $CDW2 $CDW3 $CDW4 $CDW5 $CDW6 $CDW7 $CDW8 $CDW9 $CDWa $CDWb $CDWc" NAMz="All disk writers" ############################################################################### ############################################################################### ############################################################################### ############################ START OF PROGRAM CODE ############################ ############################################################################### ############################################################################### # Run config files from default location unless -X specified. i=0 if [ ".$1" == ".-X" -o ".$1" == ".-x" ] ; then shift echo "Automatic configuration file(s) skipped by -X option." else OLDCONF="" while [ ".$CONF" != ".$OLDCONF" -a -r "$CONF" ] ; do PRECONF="$OLDCONF" OLDCONF="$CONF" echo "Running configuration file \"$CONF\"..." i=$[$i+1] . "$CONF" done if [ $i -eq 0 ] ; then echo "There were no automatic configuration files found." fi fi #------------------------------------------------------------------------------ # Then check parameter for setup files in both program and current directory. #------------------------------------------------------------------------------ if [ ".${1/%.$CFGEXT/}" != "." -a ".${1/\//}" == ".$1" -a -r "$PD${1/%.$CFGEXT/}.$CFGEXT" ] ; then echo "Running specified configuration file (from $PD) \"${1/%.$CFGEXT/}.$CFGEXT\"..." i=$[$i+1] . "$PD${1/%.$CFGEXT/}.$CFGEXT" fi if [ ".$1" != "." -a -r "$1" ] ; then echo "Running specified configuration file \"$1\"..." i=$[$i+1] . "$1" fi if [ $i -eq 0 ] ; then echo "There were no configuration files found." elif [ $i -eq 1 ] ; then echo "Finished running 1 configuration file." else echo "Finished running $i total configuration files listed above." fi $SLEEP #------------------------------------------------------------------------------ # Check for CD data directory. #------------------------------------------------------------------------------ if [ ! -d "$CD" ] ; then echo -e "${CE}The image data directory \"$CD\" does not exist.$C0" echo "Last CONF filename was \"$CONF\"" echo "Command line CONF file \"$1\"" echo "Program directory \"$PD\"" echo "Program name \"$PN\"" exit 1 fi #------------------------------------------------------------------------------ # Auto show the help file if specified by AUTOHELP. #------------------------------------------------------------------------------ if [ -r "$AUTOHELP" ] ; then if [ -s "$AUTOHELP" ] ; then $VIEW "$AUTOHELP" fi elif [ -s "$PD$AUTOHELP" ] ; then $VIEW "$PD$AUTOHELP" fi #------------------------------------------------------------------------------ # The main loop starts here. #------------------------------------------------------------------------------ quit=0 ; while [ $quit -eq 0 ] ; do # Check drives to see if there are read/write drives available. # Status may change if user runs setup, so it happens each pass thru menu. # These 2 big if statements configure the availability of R/W menu options. if [ ".${NAM1:+$CDR1}" != "." -o ".${NAM2:+$CDR2}" != "." -o \ ".${NAM3:+$CDR3}" != "." -o ".${NAM4:+$CDR4}" != "." -o \ ".${NAM5:+$CDR5}" != "." -o ".${NAM6:+$CDR6}" != "." -o \ ".${NAM7:+$CDR7}" != "." -o ".${NAM8:+$CDR8}" != "." -o \ ".${NAM9:+$CDR9}" != "." -o ".${NAMa:+$CDRa}" != "." -o \ ".${NAMb:+$CDRb}" != "." -o ".${NAMc:+$CDRc}" != "." -o \ ".${NAMd:+$CDRd}" != "." -o ".${NAMe:+$CDRe}" != "." -o \ ".${NAMf:+$CDRf}" != "." -o ".${NAMg:+$CDRg}" != "." -o \ ".${NAMh:+$CDRh}" != "." -o ".${NAMi:+$CDRi}" != "." -o \ ".${NAMj:+$CDRj}" != "." -o ".${NAMk:+$CDRk}" != "." -o \ ".${NAMl:+$CDRl}" != "." -o ".${NAMm:+$CDRm}" != "." -o \ ".${NAMn:+$CDRn}" != "." -o ".${NAMo:+$CDRo}" != "." -o \ ".${NAMp:+$CDRp}" != "." -o ".${NAMq:+$CDRq}" != "." -o \ ".${NAMr:+$CDRr}" != "." -o ".${NAMs:+$CDRs}" != "." -o \ ".${NAMt:+$CDRt}" != "." -o ".${NAMu:+$CDRu}" != "." -o \ ".${NAMv:+$CDRv}" != "." -o ".${NAMw:+$CDRw}" != "." -o \ ".${NAMx:+$CDRx}" != "." -o ".${NAMy:+$CDRy}" != "." -o \ ".${NAMz:+$CDRz}" != "." ] ; then doR=1 ; else doR=0 ; fi if [ ".${NAM1:+$CDW1}" != "." -o ".${NAM2:+$CDW2}" != "." -o \ ".${NAM3:+$CDW3}" != "." -o ".${NAM4:+$CDW4}" != "." -o \ ".${NAM5:+$CDW5}" != "." -o ".${NAM6:+$CDW6}" != "." -o \ ".${NAM7:+$CDW7}" != "." -o ".${NAM8:+$CDW8}" != "." -o \ ".${NAM9:+$CDW9}" != "." -o ".${NAMa:+$CDWa}" != "." -o \ ".${NAMb:+$CDWb}" != "." -o ".${NAMc:+$CDWc}" != "." -o \ ".${NAMd:+$CDWd}" != "." -o ".${NAMe:+$CDWe}" != "." -o \ ".${NAMf:+$CDWf}" != "." -o ".${NAMg:+$CDWg}" != "." -o \ ".${NAMh:+$CDWh}" != "." -o ".${NAMi:+$CDWi}" != "." -o \ ".${NAMj:+$CDWj}" != "." -o ".${NAMk:+$CDWk}" != "." -o \ ".${NAMl:+$CDWl}" != "." -o ".${NAMm:+$CDWm}" != "." -o \ ".${NAMn:+$CDWn}" != "." -o ".${NAMo:+$CDWo}" != "." -o \ ".${NAMp:+$CDWp}" != "." -o ".${NAMq:+$CDWq}" != "." -o \ ".${NAMr:+$CDWr}" != "." -o ".${NAMs:+$CDWs}" != "." -o \ ".${NAMt:+$CDWt}" != "." -o ".${NAMu:+$CDWu}" != "." -o \ ".${NAMv:+$CDWv}" != "." -o ".${NAMw:+$CDWw}" != "." -o \ ".${NAMx:+$CDWx}" != "." -o ".${NAMy:+$CDWy}" != "." -o \ ".${NAMz:+$CDWz}" != "." ] ; then doW=1 ; else doW=0 ; fi # ------------------------- MAIN MENU ------------------------- $CLEAR cd "$CD" echo -e "${CT}Fractal's Disk Burner Station, version Pre1.$C0" if [ ".$AUTOSHOW" == ".1" ] ; then echo "Files available for writing:" echo echo -e -n "$CL" find "$CD" -name \*.toc -printf " %TY-%Tm-%Td %TH:%TM%13s %f\n" | \ sed "s/.toc$//" | sort echo -e "$C0" fi echo "Select one of the following commands." echo if [ -r "$HELP" ] ; then echo -e "${CC}?$CM: View the help file (Q to quit).$C0" fi if [ ".$INFOCD" == ".1" ] ; then echo -e "${CC}I$CM: Get information about a disk in a reader.$C0" fi if [ ".$WIPECD" == ".1" ] ; then echo -e "${CC}E$CM: Erase re-writable disks in writer(s).$C0" fi if [ ".$doR" == ".1" ] ; then echo -e "${CC}R$CM: Read a new image file from a disk in a reader.$C0" fi if [ ".$CHANGE" == ".1" ] ; then echo -e "${CC}C$CM: Change / Create an image layout file.$C0" fi if [ ".$LSTIMG" == ".1" ] ; then echo -e "${CC}L$CM: List available image files.$C0" fi if [ ".$doW" == ".1" ] ; then echo -e "${CC}W$CM: Write disks from an image file to writer(s).$C0" fi if [ ".$TESTCD" == ".1" ] ; then echo -e "${CC}T$CM: Test (verify) a disk in a reader against a file.$C0" fi if [ ".$DELETE" == ".1" ] ; then echo -e "${CC}D$CM: Delete an image file.$C0" fi if [ ".$CONFIG" == ".1" ] ; then echo -e "${CC}S$CM: System setup and information submenu.$C0" fi for i in 1 2 3 4 5 6 7 8 9 A B C D E F ; do d="OTHDSC$i" if [ ".${!d}" != "." ] ; then o="OTHKEY$i" if [ ".${!o}" == "." ] ; then echo -e "${!d}" else echo -e "${CC}${!o}$CM${!d}$C0" fi fi done if [ ".$QUITSEP" != "." ] ; then echo -e "$QUITSEP" fi if [ ".$QUITDSC" != "." ] ; then echo -e "${CC}Q$CM$QUITDSC$C0" fi # ------------------------- Process Choice ------------------------- echo read -r -s -n 1 -p "Press a choice (by letter): " c echo $c # ----- View help file ----- if [ ".$c" == ".?" -a -r "$HELP" ] ; then $VIEW "$HELP" # ----- Get information about CD-ROM disk ----- elif [ "$INFOCD.$c" == "1.I" -o "$INFOCD.$c" == "1.i" ] ; then echo "-----------------------------" if [ ".$CD_I" != "." ] ; then i="$CD_I" else echo "Select a drive to get disk information from." echo for i in 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z ; do n="NAM$i" d="CDR$i" if [ ".${!n}" != "." -a ".${!d}" != "." ] ; then echo -e "$CC$i$CM: ${!n} (dev=${!d})$C0" fi done echo read -r -s -n 1 -p "Press a choice (by number): " i echo $i fi n="NAM$i" d="CDR$i" if [ ".$i" == "." -o ".$i" == ". " ] ; then echo "Cancelled." $SLEEP elif [ ".${!n}" == "." ] ; then echo -e "${CE}Sorry, no such drive!$C0" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else $INFOCMD ${!d} $IOPTS echo -e -n "${CB}Press any key to continue: $C0" $PAUSE fi # ----- Erase a re-writable disk ----- elif [ "$INFOCD.$c" == "1.E" -o "$INFOCD.$c" == "1.e" ] ; then echo "-----------------------------" if [ ".$CD_E" != "." ] ; then i="$CD_E" else echo "Select a drive to erase disk." echo for i in 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z ; do n="NAM$i" d="CDW$i" if [ ".${!n}" != "." -a ".${!d}" != "." ] ; then echo -e "$CC$i$CM: ${!n} (dev=${!d})$C0" fi done echo read -r -s -n 1 -p "Press a choice (by number): " i echo $i fi n="NAM$i" d="CDW$i" if [ ".$i" == "." -o ".$i" == ". " ] ; then echo "Cancelled." $SLEEP elif [ ".${!n}" == "." ] ; then echo -e "${CE}Sorry, no such drive!$C0" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else o="EOP$i" for i in ${!d} ; do $WIPECMD $i $EOPTS ${!o} & done wait echo -e -n "${CB}Press any key to continue: $C0" $PAUSE fi # ----- Read a CD-ROM disk to file ----- elif [ "$doR.$c" == "1.R" -o "$doR.$c" == "1.r" ] ; then echo "-----------------------------" space=$[`df -Pk . | awk '{print $4}' | grep -v "Available"`/10336] if [ "$space" -lt $WARNTIME ] ; then echo -e "${CE}\aWARNING!$C0" echo -e "${CE}\aWARNING!$C0" echo -e "${CB}There is space for ${CE}ONLY $space MINUTES${CB} of CD time.\a$C0" echo -e "${CE}\aWARNING!$C0" echo -e "${CE}\aWARNING!$C0" else echo -e "${CB}There is space for $space minutes of CD time.$C0" fi if [ ".$CD_R" != "." ] ; then i="$CD_R" else echo "Select a drive to read the image from." echo for i in 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z ; do n="NAM$i" d="CDR$i" if [ ".${!n}" != "." -a ".${!d}" != "." ] ; then echo -e "$CC$i$CM: ${!n} (dev=${!d})$C0" fi done echo read -r -s -n 1 -p "Press a choice (by number): " i echo $i fi n="NAM$i" d="CDR$i" if [ ".$i" == "." -o ".$i" == ". " ] ; then echo "Cancelled." $SLEEP elif [ ".${!n}" == "." ] ; then echo -e "${CE}Sorry, no such drive!$C0" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else echo "These files already exist:" echo echo -e -n "$CL" ls *.toc echo -e "$C0" echo "You do not need to enter the final \".toc\" on the filename." read -e -p "Enter a name for new file: " name name="${name//%.toc/.}" name="${name//%./}" if [ -e "$name.toc" ] ; then read -r -s -n 1 -p "$name already exists, DELETE IT? (Y/N): " junk echo $junk if [ ".$junk" != ".Y" -a ".$junk" != ".y" ] ; then name="" else rm -v "$name.toc" "$name.bin" fi fi if [ ".$name" != "." ] ; then echo echo -e "${CB}Reading \"$name\" from ${!n}.$C0" echo o="ROP$i" $READCMD ${!d} $ROPTS ${!o} \ --datafile "$name.bin" "$name.toc" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else echo "Cancelled." $SLEEP fi fi # ----- Change an image layout ----- elif [ "$CHANGE.$c" == "1.C" -o "$CHANGE.$c" == "1.c" ] ; then echo "These layout files exist:" echo echo -e -n "$CL" ls *.toc echo -e "$C0" echo "You do not need to enter the final \".toc\" on the filename." read -e -p "Edit which file: " name name="${name//%.toc/.}" name="${name//%./}" if [ ".$name" != "." ] ; then if [ -e "$name.toc" ] ; then $EDIT "$name.toc" $SLEEP else echo -e "${CE}$name does not exist.$C0" read -r -s -n 1 -p "Do you want to create it? (Y/N): " junk echo $junk if [ ".$junk" == ".Y" -o ".$junk" == ".y" ] ; then $EDIT "$name.toc" $SLEEP fi fi else echo "Cancelled." $SLEEP fi # ----- List available image files ----- elif [ "$LSTIMG.$c" == "1.L" -o "$LSTIMG.$c" == "1.l" ] ; then find . -name \*.toc -printf " %TY-%Tm-%Td %TH:%TM%13s %P\n" | \ sed "s/.toc$//" | sort | $VIEW # ----- Write a CD-ROM from image file ----- elif [ "$doW.$c" == "1.W" -o "$doW.$c" == "1.w" ] ; then echo "----------------------------" if [ ".$CD_W" != "." ] ; then i="$CD_W" else echo "Select a drive to write image to." echo for i in 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z ; do n="NAM$i" d="CDW$i" d="${!d}" if [ ".${!n}" != "." -a ".$d" != "." ] ; then if [ ".$ALLDEV" == ".1" ] ; then echo -e "$CC$i$CM: ${!n} (dev=$d)$C0" else echo -e "$CC$i$CM: ${!n} (dev=${d// */ ...})$C0" fi fi done echo read -r -s -n 1 -p "Press a choice (by number): " i echo $i fi n="NAM$i" if [ ".$i" == "." -o ".$i" == ". " ] ; then echo "Cancelled." $SLEEP elif [ ".${!n}" == "." ] ; then echo -e "${CE}Sorry, no such drive!$C0" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else echo "These files exist to write:" echo echo -e -n "$CL" ls *.toc echo -e "$C0" echo "You do not need to enter the final \".toc\" on the filename." read -e -p "Name of file to write: " name name="${name//%.toc/.}" name="${name//%./}" if [ ".$name" != "." ] ; then read -p "Number of disks to write: " qty qty=$[$qty+0] d="CDW$i" echo while [ $qty -gt 0 ] ; do echo -e "${CB}Writing \"$name\" to ${!n} ($qty to go).$C0" echo -e "${CB}You may change the number to write by entering it below.$C0" echo -e -n "${CB}LOAD DISK(S) AND PRESS ENTER (or enter \"Q\" to quit):$C0 " read junk if [ ".$junk" == ".Q" -o ".$junk" == ".q" ] ; then qty=0 elif [ ".$junk" \> ".0" -a ".$junk" \< ".999999999" ] ; then qty=$[$junk+0] echo -e "${CB}Writing \"$name\" to ${!n} ($qty to go).$C0" fi echo o="WOP$i" for i in ${!d} ; do if [ $qty -gt 0 ] ; then $WRITECMD $i $WOPTS ${!o} \ "$name.toc" & qty=$[$qty-1] fi done wait done echo -e "${CB}FINISHED WRITING!$C0" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else echo "Cancelled." $SLEEP fi fi # ----- Test a CD-ROM against an image file ----- elif [ "$TESTCD.$c" == "1.T" -o "$TESTCD.$c" == "1.t" ] ; then echo "----------------------------" if [ ".$CD_T" != "." ] ; then i="$CD_T" else echo "Select the drive which contains the disk to compare." echo for i in 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z ; do n="NAM$i" d="CDR$i" if [ ".${!n}" != "." -a ".${!d}" != "." ] ; then echo -e "$CC$i$CM: ${!n} (dev=${!d})$C0" fi done echo read -r -s -n 1 -p "Press a choice (by number): " i echo $i fi n="NAM$i" d="CDR$i" if [ ".$i" == "." -o ".$i" == ". " ] ; then echo "Cancelled." $SLEEP elif [ ".${!n}" == "." ] ; then echo -e "${CE}Sorry, no such drive!$C0" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else echo -e "${CB}NOTE: Modified layouts may not verify if overall content is different.$C0" echo "Select an image file to compare to." echo echo -e -n "$CL" ls *.toc echo -e "$C0" echo "You do not need to enter the final \".toc\" on the filename." read -e -p "Name of file to compare to: " name name="${name//%.toc/.}" name="${name//%./}" if [ ".$name" == "." ] ; then echo "Cancelled." $SLEEP elif [ -r "$name.toc" ] ; then echo echo -e "${CB}Comparing \"$name\" to disk in ${!n}.$C0" echo o="TOP$i" n=`date +%y%m%d%H%M%S%N` $VERICMD ${!d} $TOPTS ${!o} --datafile "$n.test" "$n.toc.test" $DIFFCMD "$name.bin" "$n.test" | $VIEW echo "Removing test files..." rm "$n.toc.test" "$n.test" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else echo -e "${CE}Error! No such file \"$name\".$C0" echo -e -n "${CE}Press any key to continue: $C0" $PAUSE fi fi # ----- Delete an image ----- elif [ "$DELETE.$c" == "1.D" -o "$DELETE.$c" == "1.d" ] ; then echo "These image files exist:" echo echo -e -n "$CL" ls *.toc echo -e "$C0" echo "You do not need to enter the final \".toc\" on the filename." read -e -p "Delete which file: " name name="${name//%.toc/.}" name="${name//%./}" if [ ".$name" != "." ] ; then if [ -e "$name.toc" -o -e "$name.bin" ] ; then rm -v "$name.toc" "$name.bin" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE else echo -e "\a${CE}Error! \"$name\" does not exist.$C0" echo -e -n "${CB}Press any key to continue: $C0" $PAUSE fi else echo "Cancelled." $SLEEP fi # ----- Configuration and information menu ----- elif [ "$CONFIG.$c" == "1.S" -o "$CONFIG.$c" == "1.s" -o \ ".$c" != "." -a ".$c" == ".$HOTCNF" ] ; then echo -e "${CB}Choose one of the following.$C0" echo echo -e "${CC}L$CM: View available CD-ROM devices.$C0" echo -e "${CC}D$CM: View Disk usage and free space.$C0" echo -e "${CC}F$CM: View the files in data directory.$C0" echo -e "${CC}C$CM: Cleanup any leftover test files.$C0" echo -e "${CC}M$CM: View Memory usage and swap space.$C0" echo -e "${CC}P$CM: View the program code.$C0" echo -e "${CC}V$CM: View variable values.$C0" echo -e "${CC}S$CM: View the configuration file.$C0" if [ ".$EDIT" != "." ] ; then echo -e "${CC}E$CM: Edit the configuration file.$C0" fi echo read -r -s -n 1 -p "Select an option: " i echo $i if [ ".$i" == ".L" -o ".$i" == ".l" ] ; then $LISTDEV 2>&1 | $VIEW elif [ ".$i" == ".D" -o ".$i" == ".d" ] ; then df 2>&1 | $VIEW elif [ ".$i" == ".F" -o ".$i" == ".f" ] ; then ls -l | $VIEW elif [ ".$i" == ".C" -o ".$i" == ".c" ] ; then rm -v *.test 2>&1 echo -e -n "${CB}Press any key to continue: $C0" $PAUSE elif [ ".$i" == ".M" -o ".$i" == ".m" ] ; then free 2>&1 | $VIEW elif [ ".$i" == ".P" -o ".$i" == ".p" ] ; then cat $PP 2>&1 | $VIEW elif [ ".$i" == ".V" -o ".$i" == ".v" ] ; then set | $VIEW elif [ ".$i" == ".S" -o ".$i" == ".s" ] ; then cat $CONF 2>&1 | $VIEW elif [ ".$i" == ".E" -a ".$EDIT" != "." -o ".$i" == ".e" -a ".$EDIT" != "" ] ; then $EDIT "$CONF" . "$CONF" fi # ----- Quit the program ----- elif [ ".$c" == ".Q" -o ".$c" == ".q" ] ; then quit=1 # ----- OTHER Commands defined in setup files ----- else for i in 1 2 3 4 5 6 7 8 9 A B C D E F ; do o="OTHKEY$i" if [ ".${!o}" != "." -a ".${!o}" == ".$c" ] ; then n="OTHCMD$i" n="${!n}" n="${n//\%k/${!r}}" n="${n//\% /%}" if [ ".${n:0:6}" == ".PAUSE:" ] ; then ${n:6} echo -e -n "${CB}Press any key to continue: $C0" $PAUSE elif [ ".${n:0:6}" == ".ERROR:" ] ; then ${n:6} if [ ".$?" != ".0" ] ; then echo -e -n "${CB}An error occurred. Press any key to continue: $C0" $PAUSE fi elif [ ".${n:0:12}" == ".QUERY:PAUSE:" ] ; then echo -e -n "${CB}Are you sure (Y/N): $C0" read -r -s -n 1 junk echo $junk if [ ".$junk" == ".Y" -o ".$junk" == ".y" ] ; then ${n:12} echo -e -n "${CB}Press any key to continue: $C0" $PAUSE fi elif [ ".${n:0:12}" == ".QUERY:ERROR:" ] ; then echo -e -n "${CB}Are you sure (Y/N): $C0" read -r -s -n 1 junk echo $junk if [ ".$junk" == ".Y" -o ".$junk" == ".y" ] ; then ${n:12} if [ ".$?" != ".0" ] ; then echo -e -n "${CB}An error occurred. Press any key to continue: $C0" $PAUSE fi fi elif [ ".${n:0:6}" == ".QUERY:" ] ; then echo -e -n "${CB}Are you sure (Y/N): $C0" read -r -s -n 1 junk echo $junk if [ ".$junk" == ".Y" -o ".$junk" == ".y" ] ; then ${n:6} fi else $n fi fi done fi done echo echo -e "${CB}Thank you for flying Fracware...$C0" echo sleep 1