author | nathan |
Sun, 01 Dec 2013 13:30:48 +0100 | |
branch | trunk |
changeset 17 | 4879fdaac574 |
parent 4 | 79da91042fcc |
permissions | -rw-r--r-- |
1 #!/bin/bash
3 # defaults
5 DEVICE="/dev/sr1"
6 TRACK="1"
7 LIST=0
9 # process command-line options
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))
31 # process input-files
33 TMP="/tmp/cdload.$$"
34 rm -f $TMP
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 "--"
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
53 cdrestore -d $DEVICE -t $TRACK | afio $aopt -vnz $SPECOPT -
55 rm -f $TMP