SHARE
TWEET

Untitled

a guest Apr 12th, 2012 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
Want to get better at Bash?
Learn to code Bash in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top