From abe503a507126b13b3b9bb5006bbaf2c25e3ffdc Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Wed, 11 Feb 2009 15:10:20 +0000 Subject: move disk count above (to reuse other variable) --- rescue/restore-image.sh | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'rescue/restore-image.sh') diff --git a/rescue/restore-image.sh b/rescue/restore-image.sh index 08741c9e7..9cb69d84c 100755 --- a/rescue/restore-image.sh +++ b/rescue/restore-image.sh @@ -103,8 +103,11 @@ function detect_root() first_win32_part_dev=$(grep -e "FAT\|NTFS\|HPFS" /tmp/fdisk.log | tail -1 | sed 's/ .*$//') set +f - if [ -n "${first_win32_part_dev}" ]; then + # won't handle complex layouts + if [ ! $(grep "^/dev" /tmp/fdisk.log | wc -l) -gt 1 ]; then + if [ -n "${first_win32_part_dev}" ]; then root=$(detect_and_resize_win32 $first_disk $first_win32_part_dev) + fi fi if [ -z "${root}" ]; then @@ -135,30 +138,27 @@ function detect_and_resize_win32() disk=${1} device=${2} - # won't handle complex layouts - if [ ! $(grep "^/dev" /tmp/fdisk.log | wc -l) -gt 1 ]; then - # it might be needed, for safety - device_type=$(vol_id --type ${device}) - modprobe ${device_type} - - # df for that partition - mount ${device} /mnt - size=$(df ${device} | tail -1) - umount /mnt - - # its diskspace - used=$(echo ${size} | awk '{ print $3 }') - left=$(echo ${size} | awk '{ print $4 }') - avail=$((${left}/2)) - - if [ ! ${avail} -lt ${MIN_DISKSIZE} ]; then - win32_part_dev=${device} - win32_part_type=${device_type} - # our install takes half of 'left' - win32_part_new_size=$(($((${used}+${avail}))*2)) - resize_win32 ${win32_part_dev} ${win32_part_type} ${win32_part_new_size} - echo "${disk}${number}" - fi + # it might be needed, for safety + device_type=$(vol_id --type ${device}) + modprobe ${device_type} + + # df for that partition + mount ${device} /mnt + size=$(df ${device} | tail -1) + umount /mnt + + # its diskspace + used=$(echo ${size} | awk '{ print $3 }') + left=$(echo ${size} | awk '{ print $4 }') + avail=$((${left}/2)) + + if [ ! ${avail} -lt ${MIN_DISKSIZE} ]; then + win32_part_dev=${device} + win32_part_type=${device_type} + # our install takes half of 'left' + win32_part_new_size=$(($((${used}+${avail}))*2)) + resize_win32 ${win32_part_dev} ${win32_part_type} ${win32_part_new_size} + echo "${disk}${number}" fi } -- cgit v1.2.1