--- mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall 2011/08/10 16:10:50 2724 +++ mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall 2011/09/14 11:14:44 3200 @@ -4,11 +4,15 @@ # get a suitable environment source /etc/profile +PATH="/etc/mage-profile:${PATH}" + MAGERC="/etc/mage.rc" MAGEPROFILE="alx-060" NEW_MAGE_DISTRIBUTION="unstable" -NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" -NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" +#NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" +#NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" +NEW_RSYNC="rsync://128.20.41.110/mage-alx-060" +NEW_MIRRORS="http://128.20.41.110/magellan/alx-060" NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' NEW_MAGE_UNINSTALL_TIMEOUT=0 @@ -18,7 +22,14 @@ NEW_ALX_DHCP_START="-T 10 -t 5 -n -i" NEW_ALX_DHCP_STOP="" NEW_MIN_DISK_SPACE="85000" -NEW_ALX_PLUGINS="/etc/alxconfig-ng/plugins" +NEW_ALX_PLUGINS="/usr/lib/alxconfig-ng/plugins" +NEW_ALX_FUNCTIONS="/usr/lib/alxconfig-ng/functions" + +# fake mage upgrade to prevent annoying error messages +if [[ ! -x /usr/sbin/mageupgrade ]] +then + mageupgrade() { true; }; export -f mageupgrade +fi read_value() { @@ -84,13 +95,62 @@ 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 # fix config.rc CONFIG="${CONFIGRC}" -updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS +updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS ALX_FUNCTIONS # fix profile if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] @@ -99,6 +159,16 @@ ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile fi +# fix missing /dev/root device +if [[ ! -e /dev/root ]] +then + echo "fixing missing /dev/root symlink ..." + rootdev=$(basename $(mount | grep ' / ' | cut -d' ' -f1)) + [[ -e /dev/${rootdev} ]] && ln -snf ${rootdev} /dev/root +fi + +check_mbr_size || exit 1 + # update mage3 -> mage4 if [[ -z $(magequery -n mage) ]] then @@ -165,7 +235,7 @@ if [[ -z $(magequery -n ${BASESYSTEM}) ]] then # first keep some important files - + # export bootstrap to not start any services export MAGE_BOOTSTRAP=true mage install ${BASESYSTEM} @@ -219,6 +289,12 @@ if [[ -f /.dist-upgrade ]] then + # busybox gets installed before the new busybox initscripts + # and the syslog daemon gets started at the wrong runlevels (rc3.d instead of rc.sysinit) + # these runlevel symlinks will be deleted by the prune-orphaned-files script + # and syslogd will be left never started. so add syslogd here + rc-config add syslogd + # array of wireless opts WIRELESS_OPTS=( WIRELESS_BITRATE WIRELESS_CHANNEL WIRELESS_ESSID WIRELESS_FREQUENCY WIRELESS_MODE WIRELESS_NICK WIRELESS_AUTH_MODE WIRELESS_KEY_LENGTH WIRELESS_KEY WIRELESS_KEY_ASCII WIRELESS_WPA_DRIVER ) @@ -267,6 +343,8 @@ FBMODS="uvesafb" echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::') + # run depmod before + depmod -aF /boot/System.map-${kernelver} mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver} # update grub bootloader updategrub2 @@ -274,16 +352,27 @@ if [[ -f /.dist-upgrade ]] then - echo "preparing a reboot in 60 seconds ..." + echo "preparing for a reboot in 60 seconds ..." # reboot via cronjob [[ ! -d /var/spool/cron/crontabs ]] && install -d /var/spool/cron/crontabs # setup a proper cronjob tmp=$(mktemp) - echo "* * * * * crontab -r && reboot -f" > ${tmp} + :> ${tmp} + # fake mageupgrade to fix annoying error messages + if [[ ! -x /sbin/mageupgrade ]] + then + echo '#!/bin/sh' > /sbin/mageupgrade + echo 'exit 0' >> /sbin/mageupgrade + chmod +x /sbin/mageupgrade + echo "* * * * * rm /sbin/mageupgrade" >> ${tmp} + fi + echo "* * * * * crontab -r && reboot -f" >> ${tmp} crontab ${tmp} [[ -f ${tmp} ]] && rm -f ${tmp} # start cron daemon in background crond -b -S + + rm -f /.dist-upgrade fi exit 0