]> git.sur5r.net Git - bacula/rescue/blobdiff - rescue/linux/usb/src/scripts/restore/choosedisk
Add new usb rescue key code
[bacula/rescue] / rescue / linux / usb / src / scripts / restore / choosedisk
diff --git a/rescue/linux/usb/src/scripts/restore/choosedisk b/rescue/linux/usb/src/scripts/restore/choosedisk
new file mode 100755 (executable)
index 0000000..85e4176
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+usb=`blkid |grep bs-rescue|cut -d: -f1`
+usb=${usb%?}
+
+if [ -f nozen ]; then 
+DIALOG=dialog
+else
+DIALOG=Xdialog
+fi
+
+
+s="off \\"
+if [ -f disklist ];then
+rm disklist
+fi
+if [ -f alldisks ];then
+rm alldisks
+fi
+x=1
+
+cp dial dialogtest
+
+sed -i 's/DIALOG/'$DIALOG'/g' dialogtest
+fdisk -l|grep "/dev"|grep -v loop|grep -v md|grep -v mapper|grep -v $usb|while read line;do
+b=`echo $line |cut -d" " -f1|cut -c 1`
+
+if [ "$b" = "/" ];then
+f=1
+else
+f=2
+fi
+line=`echo $line |cut -d" " -f$f`
+l=${line%?}
+X=`echo $l |tail -c2`
+echo $X | egrep '^[0-9]+$' >/dev/null 2>&1
+       if [ "$?" -eq "0" ]; then
+       l=${l%?}
+       fi
+X=`echo $l |tail -c2`
+               if [ "$X" = ":" ];then
+               l=${l%?}
+               fi
+       cat working/diffdir/newdiskorder |grep $l|while read LINE;do
+       echo $LINE|cut -d" " -f1|grep $l>>/dev/null
+               if [ $? = 0 ];then
+               echo $LINE|cut -d" " -f 2-3>previous
+               break
+               fi
+
+                       
+               done
+touch previous
+previous=`cat previous`
+previous='"'$previous'"'
+rm previous
+
+                       if [ "$previous" = "" ];then
+                       previous="-"
+                       fi
+echo $line $previous $s >>dialogtest
+echo $x>tmp
+echo $line>>alldisks
+x=$(( x + 1 ))
+
+done
+y=`cat tmp`
+rm tmp
+sed -i s/zzz/$y/g dialogtest
+echo "2>ans">>dialogtest
+chmod +x dialogtest
+./dialogtest
+if [ ! $? = 0 ];then
+exit 1
+fi
+
+a=1
+sed -i 's@//@ /@g' ans
+sed -i 's@:@ @g' ans
+
+b=`cat ans|wc -w`
+
+for i in `seq 1 $b`;do
+answer=`cat ans |awk "{ print \$ $i }"`
+echo $answer"">>disklist
+done
+
+