9 part=`echo $disk|cut -d"/" -f3`
10 fdisk -l /dev/$part |grep bytes|grep -v Units|awk '{print $5}'>samesize
11 cat working/diskinfo/fdisk.$part |grep bytes|grep -v Units|awk '{print $5}'>samesize2
12 diff samesize samesize2 >/dev/null 2>&1
14 nowdisk=`cat samesize`
15 oldisk=`cat samesize2`
19 $DIALOG --title "different disk" --msgbox "The size of the disk you are trying to restore \n and the one we have backed up differ for /dev/$part \n \n The old disk size was $oldisk \n And the actual disk size is $nowdisk \n \n We'll have to do things manually" 60 60
20 oldiskparted=`cat working/diskinfo/parted.$part`
21 howmanyparts=`cat working/diskinfo/parted.$part|wc -l`
22 howmanyparts=$(( $howmanyparts - 7 ))
23 $DIALOG --title "different disk" --yesno "Do you want to do it manually \n ( we will launch gparted) (yes) \n Or only adjust the LAST partition size to fit the disk ? (no)" 60 60
25 if [ $DIALOG = Xdialog ];then
27 $DIALOG --title "different disk" --msgbox "the old partition sizes for this disk was \n \n $oldiskparted \n \n We will now launch gparted so you can adjust you disk partitions " 60 60
30 $DIALOG --title "different disk" --msgbox "the old partition sizes for this disk was \n \n $oldiskparted \n \n please use fdisk or cfdisk to repartition your drive \n \n and the re-run this script pointing to the partitions of the new disks \n (like /dev/sda1 ) instead of the whole disk (/dev/sda)" 60 60
35 a=` sfdisk -n /dev/$part < working/diskinfo/sfdisk.$part.make.bsi 2>&1`
39 tr ' ' '\n' < tmp >tmp2
40 cat tmp2|awk /given/,/sfdisk/ >tmp3
41 currentsize=`cat tmp3|grep -m1 "("|cut -d"(" -f2 |cut -d")" -f1`
42 maxsize=`cat tmp3|grep -m2 "("|cut -d"(" -f2 |cut -d")" -f1|tail -n1`
43 sed -i "s/$currentsize/$maxsize/g" working/diskinfo/sfdisk.make.$part.bsi
45 while [ $nowarn = 1 ];do
46 a=` sfdisk -n /dev/$part < working/diskinfo/sfdisk.$part.make.bsi 2>&1`
50 tr ' ' '\n' < tmp >tmp2
51 cat tmp2|awk /given/,/sfdisk/ >tmp3
52 currentsize=`cat tmp3|grep -m1 "("|cut -d"(" -f2 |cut -d")" -f1`
53 maxsize=`cat tmp3|grep -m2 "("|cut -d"(" -f2 |cut -d")" -f1|tail -n1`
54 sed -i "s/$currentsize/$maxsize/g" working/diskinfo/sfdisk.make.$part.bsi
59 partprobe /dev/$part >/dev/null 2>&1
61 sfdisk /dev/$part < working/diskinfo/sfdisk.$part.make.bsi