]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/usb/src/scripts/restore/choosedisk
Add new usb rescue key code
[bacula/rescue] / rescue / linux / usb / src / scripts / restore / choosedisk
1 #!/bin/sh
2
3 usb=`blkid |grep bs-rescue|cut -d: -f1`
4 usb=${usb%?}
5
6 if [ -f nozen ]; then 
7 DIALOG=dialog
8 else
9 DIALOG=Xdialog
10 fi
11
12
13 s="off \\"
14 if [ -f disklist ];then
15 rm disklist
16 fi
17 if [ -f alldisks ];then
18 rm alldisks
19 fi
20 x=1
21
22 cp dial dialogtest
23
24 sed -i 's/DIALOG/'$DIALOG'/g' dialogtest
25 fdisk -l|grep "/dev"|grep -v loop|grep -v md|grep -v mapper|grep -v $usb|while read line;do
26 b=`echo $line |cut -d" " -f1|cut -c 1`
27
28 if [ "$b" = "/" ];then
29 f=1
30 else
31 f=2
32 fi
33 line=`echo $line |cut -d" " -f$f`
34 l=${line%?}
35 X=`echo $l |tail -c2`
36 echo $X | egrep '^[0-9]+$' >/dev/null 2>&1
37         if [ "$?" -eq "0" ]; then
38         l=${l%?}
39         fi
40 X=`echo $l |tail -c2`
41                 if [ "$X" = ":" ];then
42                 l=${l%?}
43                 fi
44         cat working/diffdir/newdiskorder |grep $l|while read LINE;do
45         echo $LINE|cut -d" " -f1|grep $l>>/dev/null
46                 if [ $? = 0 ];then
47                 echo $LINE|cut -d" " -f 2-3>previous
48                 break
49                 fi
50
51                         
52                 done
53 touch previous
54 previous=`cat previous`
55 previous='"'$previous'"'
56 rm previous
57
58                         if [ "$previous" = "" ];then
59                         previous="-"
60                         fi
61 echo $line $previous $s >>dialogtest
62 echo $x>tmp
63 echo $line>>alldisks
64 x=$(( x + 1 ))
65
66 done
67 y=`cat tmp`
68 rm tmp
69 sed -i s/zzz/$y/g dialogtest
70 echo "2>ans">>dialogtest
71 chmod +x dialogtest
72 ./dialogtest
73 if [ ! $? = 0 ];then
74 exit 1
75 fi
76
77 a=1
78 sed -i 's@//@ /@g' ans
79 sed -i 's@:@ @g' ans
80
81 b=`cat ans|wc -w`
82
83 for i in `seq 1 $b`;do
84 answer=`cat ans |awk "{ print \$ $i }"`
85 echo $answer"">>disklist
86 done
87
88