2014-06-19 08:22:41 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#Used only by sysclone
|
|
|
|
|
2014-06-23 09:00:26 +00:00
|
|
|
# SI post-install script to configure the efi boot mgr or grub after SI has installed the OS
|
|
|
|
# SI post-install scripts run in a chroot environment of the final OS image
|
|
|
|
|
2013-08-23 05:58:53 +00:00
|
|
|
if [ -d /sys/firmware/efi ]; then
|
|
|
|
echo "Setting Boot Manager for the next boot."
|
2013-08-27 03:16:47 +00:00
|
|
|
echo "delete all sysclone boot list"
|
|
|
|
str_bootnums=`efibootmgr | grep 'syscloneLinux' | awk '{print $1}' | sed 's/boot//i' | sed 's/*//'`
|
|
|
|
for str_num in $str_bootnums
|
|
|
|
do
|
|
|
|
efibootmgr -b $str_num -B -q
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -f "/boot/efi/EFI/redhat/grub.efi" ];then
|
|
|
|
efibootmgr -c -l \\EFI\\redhat\\grub.efi -L syscloneLinux
|
|
|
|
elif [ -f "/boot/efi/efi/SuSE/elilo.efi" ];then
|
|
|
|
efibootmgr -c -l \\efi\\SuSE\\elilo.efi -L syscloneLinux
|
|
|
|
else
|
|
|
|
echo "Can not find the boot loader."
|
|
|
|
exit 1
|
|
|
|
fi
|
2013-08-23 05:58:53 +00:00
|
|
|
else
|
|
|
|
echo "run grub-install to configure the MBR."
|
|
|
|
if [ -e /etc/mtab ];then
|
|
|
|
mv /etc/mtab /etc/mtab.bak
|
|
|
|
fi
|
|
|
|
grep -v rootfs /proc/mounts > /etc/mtab
|
|
|
|
boot_device=''
|
|
|
|
if [ -f "/etc/systemconfig/systemconfig.conf" ];then
|
2014-07-02 09:20:51 +00:00
|
|
|
boot_root=`cat /etc/systemconfig/systemconfig.conf | grep ROOTDEV | awk '{print $3}'`
|
2013-08-23 05:58:53 +00:00
|
|
|
boot_device=`cat /etc/systemconfig/systemconfig.conf | grep BOOTDEV | awk '{print $3}'`
|
|
|
|
else
|
2014-06-23 09:00:26 +00:00
|
|
|
boot_root=`mount | grep -E ' on\s+/ type ' | awk '{print $1}'`
|
|
|
|
boot_device=`echo $boot_root | sed -e 's/[0-9]*$//'`
|
|
|
|
|
|
|
|
#str_temp=`mount | awk '{print $1","$3}'`
|
|
|
|
#for line in $str_temp
|
|
|
|
#do
|
|
|
|
# mp=`echo $line | awk -F, '{print $2}'`
|
|
|
|
# if [ "$mp" = "/" ];then
|
|
|
|
# boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'`
|
|
|
|
# break
|
|
|
|
# fi
|
|
|
|
#done
|
2013-08-23 05:58:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$boot_device" ];then
|
2014-06-23 09:00:26 +00:00
|
|
|
echo "The boot device is $boot_device"
|
|
|
|
echo "The boot root device is $boot_root"
|
2013-08-23 05:58:53 +00:00
|
|
|
else
|
|
|
|
echo "Can not find the boot device, return error"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-06-23 09:00:26 +00:00
|
|
|
# set grub to use this boot device
|
|
|
|
if grep -qe '^VERSION\s*=\s*11' /etc/SuSE-release; then
|
2013-09-23 08:07:55 +00:00
|
|
|
#sles11, run grub-install.unsupported directly
|
2014-06-23 09:00:26 +00:00
|
|
|
echo "grub-install.unsupported --no-floppy --recheck $boot_device"
|
2013-09-23 08:07:55 +00:00
|
|
|
grub-install.unsupported --no-floppy --recheck $boot_device
|
2014-06-23 09:00:26 +00:00
|
|
|
# note: the error about grub-set-default not existing is harmless, because we want the default to be 0 anyway
|
|
|
|
else
|
|
|
|
#for sles10, should run grub-install with parameters
|
|
|
|
echo "grub-install --no-floppy --recheck $boot_device"
|
|
|
|
grub-install --no-floppy --recheck $boot_device
|
2013-08-23 05:58:53 +00:00
|
|
|
fi
|
2014-06-23 09:00:26 +00:00
|
|
|
|
|
|
|
# change the entries in the grub conf file to use the correct boot root device
|
|
|
|
# (not the one leftover from the golden image)
|
|
|
|
if [ -f "/boot/grub/grub.conf" ];then
|
|
|
|
conffile="/boot/grub/grub.conf"
|
|
|
|
else
|
|
|
|
conffile="/boot/grub/menu.lst"
|
|
|
|
fi
|
|
|
|
sed -i 's| root=\S*| root='$boot_root'|' $conffile
|
|
|
|
sed -i 's| resume=\S*| noresume|' $conffile
|
|
|
|
|
2013-08-23 05:58:53 +00:00
|
|
|
if [ -e /etc/mtab.bak ];then
|
|
|
|
mv -f /etc/mtab.bak /etc/mtab
|
|
|
|
else
|
|
|
|
rm -f /etc/mtab
|
|
|
|
fi
|
|
|
|
fi
|