--- mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall 2011/09/01 10:15:46 2823 +++ mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall 2011/09/14 11:14:44 3200 @@ -4,6 +4,8 @@ # get a suitable environment source /etc/profile +PATH="/etc/mage-profile:${PATH}" + MAGERC="/etc/mage.rc" MAGEPROFILE="alx-060" NEW_MAGE_DISTRIBUTION="unstable" @@ -93,6 +95,55 @@ grub-install --no-floppy "${bootdisk}" } +# checks size of the mbr, if we are able to install grub2 +check_mbr_size() +{ + local hdd="$1" + local geometry_sectors + local partition_start_sector + local retval + + hdd="$(mount | grep '/dev/' | grep ' / ' | cut -d' ' -f1 | sed 's:\(.*\)[0-9].*:\1:')" + + if [[ -z ${hdd} ]] + then + echo "check_mbr_size(): No hdd given, aborting" + return 1 + fi + + # fix permissions + chmod +x /etc/mage-profile/sfdisk > /dev/null + + # default retval is 0 + retval=0 + + # check only if disk size is below 256mb + if [[ $(sfdisk -s ${hdd}) -lt 257000 ]] + then + geometry_sectors=$(sfdisk -g ${hdd} | sed 's:.*,\ \([0-9].*\)\ sectors.*:\1:') + partition_start_sector=$(sfdisk -d /dev/hda | grep /dev/hda1 | sed -e 's:.*start=\(.*\), size.*:\1:' -e 's:\ ::g') + + # check start_sector / geomtry > 1 then everything is fine, else abort setup as grub may not install! + if [[ $(expr ${partition_start_sector} / ${geometry_sectors}) -gt 1 ]] + then + echo "Current partition setup is big enough, to install grub2 mbr to this disk." + retval=0 + else + echo "Warning: Current partition setup to small, cannot install grub2 boot-sector to this disk." + echo "Maybe this is a *RANGEE* with a flash-disk =<256MB. Please re-install this client." + echo "Upgrade *not* supported!" + retval=1 + killall mage &> /dev/null + killall update-alx &> /dev/null + fi + else + echo "Current disk is big enough, to install grub2 mbr to this disk." + retval=0 + fi + + return "${retval}" +} + # fix mage.rc CONFIG="${MAGERC}" updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT @@ -116,6 +167,8 @@ [[ -e /dev/${rootdev} ]] && ln -snf ${rootdev} /dev/root fi +check_mbr_size || exit 1 + # update mage3 -> mage4 if [[ -z $(magequery -n mage) ]] then