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