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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
#!/bin/sh
# This file is Copyright (C) 1995-1997 by Karsten Ballder (Ballueder@usa.net)
#
# It is part of the KBackup package, see the file COPYING for details.
# KBackup and all files included in this package are licensed and protected
# under the terms and conditions of the GNU General Public License Version 2.
#
# If you want to contact the current maintainer of this software, please
# send e-mail to: KBackup@usa.net
AUTODETECT_SRC_LOADED=YES
test_tape_device_II()
{
tape="$1"
InfoBox "Testing $tape:\nrewinding..."
my_mt -f "$tape" rewind 2>/dev/null
if [ $? != 0 ]
then
return 1
fi
mysleep 5
my_mt -f "$tape" rewind 2>/dev/null
if [ $? = 0 ]
then
mysleep 5
InfoBox "Testing $tape:\nwriting 1st pattern..."
( echo "Tape device is working correctly (non-rewinding)." | \
$DD of="$tape" obs=$syncto conv=sync ) 2>/dev/null
if [ $? != 0 ]
then
return 1
fi
mysleep 5
InfoBox "Testing $tape:\nwriting 2nd pattern..."
( echo "Tape device is incompatible with KBackup (rewinding)." | \
$DD of="$tape" obs=$syncto conv=sync ) 2>/dev/null
if [ $? != 0 ]
then
return 1
fi
mysleep 5
InfoBox "Testing $tape:\nrewinding... "
my_mt -f "$tape" rewind 2>/dev/null
mysleep 5
my_mt -f "$tape" rewind 2>/dev/null
mysleep 5
InfoBox "Testing $tape:\nreading... "
cat "$tape" | $FGREP "non-rewinding" >/dev/null 2>/dev/null
return $?
else
return 1 # error
fi
}
#
# scans system for KBackup compatible tape devices and returns
# the list of device names in $TMP/$TMPFILE2
#
autodetect_tape_device_II()
{
$DIALOG --title " WARNING ! " --yesno \
"
Please insert an empty tape into your drive.
Furtheron, this might give unpredictable side
effects, as your kernel might try to load
additional kernel modules.
USE THIS AT YOUR OWN RISK and only if you
know what you are doing!
This test will erase any data on the tape!
Are you sure that you want to continue?" 16 50
if [ $? != 0 ]
then
return
fi
echo >$TMP/$TMPFILE2
InfoBox "Looking for devices..."
devices=`ls /dev/[n]st* /dev/[n]tpqic* /dev/[r]mt* /dev/*tape /dev/n[r]ft* /dev/[r]ft* /dev/*mt* | sort | uniq`
for i in $devices
do
InfoBox "Trying to reset driver..."
if [ -r "$resetdevice" ]
then
cat "$resetdevice" 2>/dev/null >/dev/null
fi
InfoBox "Looking for: $i"
$DD if="$i" of=/dev/null bs=0 count=0 2>$TMP/$TMPFILE >/dev/null
$FGREP "No such device" $TMP/$TMPFILE >/dev/null
if [ $? != 0 ]
then
echo "$i" >>$TMP/$TMPFILE2
fi
done
devices=`cat $TMP/$TMPFILE2`
count=1
echo >$TMP/$TMPFILE2
tape_detected=NO
for i in $devices
do
InfoBox "Trying to reset driver..."
if [ -r "$resetdevice" ]
then
cat "$resetdevice" 2>/dev/null >/dev/null
fi
test_tape_device_II "$i"
if [ $? = 0 ]
then
echo "$i ok" >>$TMP/$TMPFILE2
tape_detected=YES
fi
done
}
autodetect_tape_menu()
{
if [ "$tape_detected" = "YES" ]
then
$DIALOG --title " Autodetection " --menu "
These devices have been detected as being
available and compatible for use with KBackup.
Please choose one from the list.
" 20 60 6 `cat $TMP/$TMPFILE2` 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
device=`cat $TMP/$DIALOGFILE`
device_type=TAPE
Configuration_changed=YES
fi
else
MsgBox "
No compatible tape device found.
"
fi
}
|