Skip to content

Commit

Permalink
mxgrub: Add --set-default to switch default kernel
Browse files Browse the repository at this point in the history
Add new command `mxgrub --set-default {label}` which sets the default
kernel. It is not automatically selected for the next boot.

Note, that the designation of the default kernel is via the symlink
/boot/bzImage.x86_64, which is distributed by the distmaster.

Resolves #74
  • Loading branch information
donald committed Aug 20, 2019
1 parent c881fbb commit 8892188
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mxgrub/mxgrub
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sub USAGE { return <<"EOF" }
$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
$0 --set-default {label} : select this kernel as the default kernel
EOF

sub sys {
Expand Down Expand Up @@ -363,17 +364,27 @@ sub cmd_reboot {
sys('kexec',"/boot/$image",'--initrd=/boot/grub/initramfs.igz',"--command-line=root=LABEL=root $KERNEL_PARAMETER");
}

sub cmd_set_default {
my ($label)=@_;
my $image=label_to_image($label);
-e "/boot/$image" or die "/boot/$image: no such file\n";
sys 'ln','-sf',$image,'/boot/bzImage.x86_64';
scan_mariux(0);
update_grub_cfg();
}

umask 022;
check_grub_installation();

our ($opt_list,$opt_update,$opt_initramfs,$opt_test,$opt_reboot);
our ($opt_list,$opt_update,$opt_initramfs,$opt_test,$opt_reboot,$opt_set_default);

GetOptions(
'list' => \$opt_list,
'update' => \$opt_update,
'initramfs' => \$opt_initramfs,
'test' => \$opt_test,
'reboot' => \$opt_reboot,
'set-default' => \$opt_set_default,

) or die USAGE;

Expand Down Expand Up @@ -407,6 +418,9 @@ if ($opt_list) {
} elsif ($opt_reboot) {
@ARGV==0 or die USAGE;
cmd_reboot();
} elsif ($opt_set_default) {
@ARGV==1 or die USAGE;
cmd_set_default($ARGV[0]);
} else {
@ARGV==1 or die USAGE;
cmd_install($ARGV[0]);
Expand Down

0 comments on commit 8892188

Please sign in to comment.