Skip to content

Commit

Permalink
Merge pull request #13 from mariux64/grub-submenu
Browse files Browse the repository at this point in the history
add submenu for grub
  • Loading branch information
donald authored Sep 27, 2017
2 parents c37bbc6 + 56916ee commit ed2336b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mxgrub/mxgrub
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ sub is_VX50 {
return $data=~/VX50/;
}

our $submenu="all-other-kernel";

sub get_chosen {
my $chosen;
open my $p,'-|','grub-editenv','-','list' or die "$!\n";
while (<$p>) {
/^chosen=(.+)/ and return $1;
/^chosen=(?:$submenu>)?(.+)/ and return $1;
}
close $p or die "$!\n";
$? and exit 1;
Expand Down Expand Up @@ -203,11 +205,15 @@ if [ -e /etc/local/USB.usb ]; then
menuentry "mariuxUSB" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 crashkernel=256M root=LABEL=rootusb ro ; initrd /boot/grub/initramfs.igz }
else
menuentry "$MARIUX_DEFAULT" --unrestricted { set chosen="$submenu>$MARIUX_DEFAULT" ; save_env chosen ; linux /boot/bzImage.x86_64 crashkernel=256M root=LABEL=root ro console=ttyS1,115200n8 console=tty0 ; initrd /boot/grub/initramfs.igz }
submenu "$submenu" --unrestricted {
$kernellist
if [ \$chosen ]; then
set default=\$chosen
unset chosen # must be clear to get a clean value from menuentry
fi
}
if [ \$chosen ]; then
set default=\$chosen
unset chosen # must be clear to get a clean value from menuentry
fi
fi
EOF

Expand Down Expand Up @@ -259,7 +265,7 @@ sub cmd_install {
if ($label eq 'default') {
sys('grub-editenv','-','set',"chosen=$MARIUX_DEFAULT");
} else {
sys('grub-editenv','-','set',"chosen=$label");
sys('grub-editenv','-','set',"chosen=$submenu>$label");
}
}

Expand Down

0 comments on commit ed2336b

Please sign in to comment.