examples/cdload
branchtrunk
changeset 4 79da91042fcc
equal deleted inserted replaced
3:d09ec85ffdfe 4:79da91042fcc
       
     1 #!/bin/bash 
       
     2 
       
     3 # defaults
       
     4 
       
     5 DEVICE="/dev/sr1"
       
     6 TRACK="1"
       
     7 LIST=0
       
     8 
       
     9 # process command-line options
       
    10 
       
    11 while getopts ":d:t:l" optn; do
       
    12     case $optn in
       
    13     d ) DEVICE=$OPTARG
       
    14         ;;
       
    15     t ) TRACK=$OPTARG
       
    16         ;;
       
    17     l ) LIST=1
       
    18         ;;
       
    19     \? ) echo "Usage: `basename $0` [-d device] [-t track] [-l] [filespec]"
       
    20          echo ""
       
    21 	 echo "Defaults: -d /dev/sr1"
       
    22 	 echo "          -t 1"
       
    23          echo ""
       
    24 	 echo "if -l is given, archive is listed not restored."
       
    25         exit 1  
       
    26         ;;
       
    27     esac
       
    28 done
       
    29 shift $(($OPTIND - 1))
       
    30 
       
    31 #   process input-files
       
    32 
       
    33 TMP="/tmp/cdload.$$"
       
    34 rm -f $TMP
       
    35 
       
    36 SPECOPT=""
       
    37 for filespec in "$@"; do
       
    38     echo "$filespec" >>$TMP
       
    39     SPECOPT="-w $TMP"
       
    40     done
       
    41 #echo "-$SPECOPT-"
       
    42 #cat $TMP
       
    43 #echo "--"
       
    44 
       
    45 if [ $LIST -eq 1 ]; then
       
    46   aopt="-t"	# list archive
       
    47   echo "`basename $0`: listing archive"
       
    48 else
       
    49   aopt="-i"	# restore archive
       
    50   echo "`basename $0`: restoring archive"
       
    51 fi
       
    52 
       
    53 cdrestore -d $DEVICE -t $TRACK | afio $aopt -vnz $SPECOPT -
       
    54 
       
    55 rm -f $TMP