Advertisement
Guest User

Untitled

a guest
Apr 12th, 2012
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.02 KB | None | 0 0
  1. #! /bin/sh -e
  2.  
  3. CDROM=/dev/cdrom
  4. PREFIX=pegasus
  5.  
  6. copy_from_disc() {
  7.     while read -r type srcfile
  8.     do
  9.     if [ -z "$type" -o "$type" = "#" ]
  10.     then
  11.         continue
  12.     fi
  13.  
  14.     drive=`echo $srcfile | cut -d ':' -f 1`
  15.  
  16.     if [ "$drive" != "$1" ]
  17.     then
  18.         continue
  19.     fi
  20.  
  21.     dstfile=$PREFIX/`echo $srcfile | cut -d ':' -f 3- | tr ':/' '/_'`
  22.  
  23.     case $type in
  24.         D)
  25.         options=
  26.         ;;
  27.         M)
  28.         options=-m
  29.         dstfile=$dstfile.bin
  30.         ;;
  31.         R)
  32.         options=-r
  33.         ;;
  34.     esac
  35.  
  36.     if [ $type = "D" ]
  37.     then
  38.         if [ ! -d "$dstfile" ]
  39.         then
  40.         echo "Creating directory $dstfile"
  41.         mkdir -p "$dstfile"
  42.         fi
  43.     else
  44.         if [ ! -f "$dstfile" ]
  45.         then
  46.         echo "Copying: $srcfile"
  47.         hcopy $options "$srcfile" "$dstfile"
  48.         else
  49.         echo "Skipping file: $srcfile"
  50.         fi
  51.     fi
  52.     done < filelist.txt
  53. }
  54.  
  55. mkdir -p "$PREFIX"
  56.  
  57. for disc in "PP Disk 1" "PP Disk 2" "PP Disk 3" "PP Disk 4"
  58. do
  59.     read -p "Insert CD '$disc', then press Enter..." nothing
  60.     hmount $CDROM
  61.     copy_from_disc "$disc"
  62.     humount $CDROM
  63. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement