diff --git a/mxgrub/mxgrub b/mxgrub/mxgrub index d3eccf1..0aedd08 100755 --- a/mxgrub/mxgrub +++ b/mxgrub/mxgrub @@ -11,6 +11,7 @@ sub USAGE { return <<"EOF" } $0 --update : only scan /boot and rewrite grub.cfg $0 --initramfs : update /boot/grub/initramfs.igz from /project/admin/initramfs $0 --test : perform miscellaneous tests (VX50 board) + $0 --reboot : attempt kexec reboot of selected kernel EOF sub sys { @@ -352,16 +353,26 @@ sub cmd_initramfs { sys('bash','-c','cd /project/admin/initramfs;find .|cpio -H newc -o | gzip > /boot/grub/initramfs.igz'); } +sub cmd_reboot { + my $chosen=get_chosen(); + my $image=label_to_image($chosen); + -e "/boot/$image" or die "/boot/$image: no such file\n"; + sys('sync'); + sys('kexec',"/boot/$image",'--reuse-cmdline','--initrd=/boot/grub/initramfs.igz'); +} + umask 022; check_grub_installation(); -our ($opt_list,$opt_update,$opt_initramfs,$opt_test); +our ($opt_list,$opt_update,$opt_initramfs,$opt_test,$opt_reboot); GetOptions( 'list' => \$opt_list, 'update' => \$opt_update, 'initramfs' => \$opt_initramfs, 'test' => \$opt_test, + 'reboot' => \$opt_reboot, + ) or die USAGE; $opt_list && $opt_update and die USAGE; @@ -391,6 +402,9 @@ if ($opt_list) { } else { print "System booted using UEFI: no\n"; } +} elsif ($opt_reboot) { + @ARGV==0 or die USAGE; + cmd_reboot(); } else { @ARGV==1 or die USAGE; cmd_install($ARGV[0]);