mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
udpate grub to add menu and add MBR
This commit is contained in:
parent
cb4b2aad19
commit
af7dcebb25
4 changed files with 99 additions and 8 deletions
|
@ -46,7 +46,7 @@ def tasks(tasklist, manifest):
|
||||||
#apt.AptUpgrade(),
|
#apt.AptUpgrade(),
|
||||||
boot.ConfigureGrub(),
|
boot.ConfigureGrub(),
|
||||||
filesystem.ModifyFstab(),
|
filesystem.ModifyFstab(),
|
||||||
#filesystem.InstallMbr(),
|
filesystem.InstallMbr(),
|
||||||
boot.BlackListModules(),
|
boot.BlackListModules(),
|
||||||
boot.DisableGetTTYs(),
|
boot.DisableGetTTYs(),
|
||||||
security.EnableShadowConfig(),
|
security.EnableShadowConfig(),
|
||||||
|
|
|
@ -17,8 +17,14 @@ GRUB_DEVICE=/dev/sda1
|
||||||
|
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
default ${GRUB_DEFAULT}
|
set default ${GRUB_DEFAULT}
|
||||||
timeout ${GRUB_TIMEOUT}
|
set timeout ${GRUB_TIMEOUT}
|
||||||
|
insmod part_msdos
|
||||||
|
insmod ext4
|
||||||
|
insmod gettext
|
||||||
|
set menu_color_normal=cyan/blue
|
||||||
|
set meu_color_highlight=white/blue
|
||||||
|
set root='(hd0,msdos1)'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if ${GRUB_HIDDEN_TIMEOUT:-false}; then
|
if ${GRUB_HIDDEN_TIMEOUT:-false}; then
|
||||||
|
@ -34,10 +40,15 @@ linux_entry ()
|
||||||
title="$(gettext_quoted "%s, with Linux %s")"
|
title="$(gettext_quoted "%s, with Linux %s")"
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
title ${version}
|
menuentry 'Debian GNU/Linux, ${version}' --class debian --class gnu-linux --class os {
|
||||||
root (hd0)
|
insmod part_msdos
|
||||||
kernel ${rel_dirname}/${basename} root=${GRUB_DEVICE} ro ${args}
|
insmod ext4
|
||||||
|
set root='(hd0,msdos1)'
|
||||||
|
echo 'Loading Linux ${version}'
|
||||||
|
linux ${rel_dirname}/${basename} root=${GRUB_DEVICE} ro ${args}
|
||||||
|
echo 'Loading initial ramdisk ...'
|
||||||
initrd ${rel_dirname}/${initrd}
|
initrd ${rel_dirname}/${initrd}
|
||||||
|
}
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
81
providers/one/assets/grub.d/40_custom.orig
Normal file
81
providers/one/assets/grub.d/40_custom.orig
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This file generates the old menu.lst configuration with grub2
|
||||||
|
# It was copied from tomheadys github repo:
|
||||||
|
# https://github.com/tomheady/ec2debian/blob/master/src/root/etc/grub.d/40_custom
|
||||||
|
|
||||||
|
prefix=/usr
|
||||||
|
exec_prefix=${prefix}
|
||||||
|
bindir=${exec_prefix}/bin
|
||||||
|
libdir=${exec_prefix}/lib
|
||||||
|
. ${libdir}/grub/grub-mkconfig_lib
|
||||||
|
|
||||||
|
export TEXTDOMAIN=grub
|
||||||
|
export TEXTDOMAINDIR=${prefix}/share/locale
|
||||||
|
|
||||||
|
GRUB_DEVICE=/dev/sda1
|
||||||
|
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
default ${GRUB_DEFAULT}
|
||||||
|
timeout ${GRUB_TIMEOUT}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if ${GRUB_HIDDEN_TIMEOUT:-false}; then
|
||||||
|
printf "hiddenmenu\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
linux_entry ()
|
||||||
|
{
|
||||||
|
os="$1"
|
||||||
|
version="$2"
|
||||||
|
args="$4"
|
||||||
|
|
||||||
|
title="$(gettext_quoted "%s, with Linux %s")"
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
title ${version}
|
||||||
|
root (hd0)
|
||||||
|
kernel ${rel_dirname}/${basename} root=${GRUB_DEVICE} ro ${args}
|
||||||
|
initrd ${rel_dirname}/${initrd}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* ; do
|
||||||
|
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
|
||||||
|
done`
|
||||||
|
prepare_boot_cache=
|
||||||
|
|
||||||
|
while [ "x$list" != "x" ] ; do
|
||||||
|
linux=`version_find_latest $list`
|
||||||
|
basename=`basename $linux`
|
||||||
|
dirname=`dirname $linux`
|
||||||
|
rel_dirname=`make_system_path_relative_to_its_root $dirname`
|
||||||
|
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
|
||||||
|
alt_version=`echo $version | sed -e "s,\.old$,,g"`
|
||||||
|
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
|
||||||
|
|
||||||
|
initrd=
|
||||||
|
for i in "initrd.img-${version}" "initrd-${version}.img" \
|
||||||
|
"initrd-${version}" "initramfs-${version}.img" \
|
||||||
|
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
|
||||||
|
"initrd-${alt_version}" "initramfs-${alt_version}.img"; do
|
||||||
|
if test -e "${dirname}/${i}" ; then
|
||||||
|
initrd="$i"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
initramfs=
|
||||||
|
for i in "config-${version}" "config-${alt_version}"; do
|
||||||
|
if test -e "${dirname}/${i}" ; then
|
||||||
|
initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${dirname}/${i}" | cut -f2 -d= | tr -d \"`
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
linux_entry "${OS}" "${version}" \
|
||||||
|
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
|
||||||
|
|
||||||
|
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
|
||||||
|
done
|
|
@ -145,5 +145,4 @@ class InstallMbr(Task):
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, 'install-mbr', '/dev/sda'])
|
log_check_call(['install-mbr', info.manifest.bootstrapper['image_file']])
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, 'fdisk', '-l', '/dev/sda'])
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue