Add timeout support to grubby
Signed-off-by: Marta Lewandowska <mlewando@redhat.com>
This commit is contained in:
parent
4c1f179617
commit
d8ebc020d7
109
grubby-bls
109
grubby-bls
@ -545,6 +545,65 @@ update_bls_fragment() {
|
||||
update_grubcfg
|
||||
}
|
||||
|
||||
update_timeout() {
|
||||
local timeout=$1 && shift
|
||||
if [[ $timeout =~ ^[0-9]+$ ]]; then
|
||||
if grep -q "^GRUB_TIMEOUT=.*" ${grub_etc_default} ; then
|
||||
sed -i -e "s/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=${timeout}/" ${grub_etc_default}
|
||||
else
|
||||
echo GRUB_TIMEOUT=${timeout} >> ${grub_etc_default}
|
||||
fi
|
||||
RUN_MKCONFIG=true
|
||||
update_grubcfg
|
||||
fi
|
||||
}
|
||||
|
||||
update_blscfg() {
|
||||
local blscfg=$1 && shift
|
||||
if [[ $blscfg == true ]] || [[ $blscfg == false ]]; then
|
||||
if grep -q "^GRUB_ENABLE_BLSCFG=.*" ${grub_etc_default} ; then
|
||||
sed -i -e "s/^GRUB_ENABLE_BLSCFG=.*/GRUB_ENABLE_BLSCFG=${blscfg}/" ${grub_etc_default}
|
||||
else
|
||||
echo GRUB_ENABLE_BLSCFG=${blscfg} >> ${grub_etc_default}
|
||||
fi
|
||||
RUN_MKCONFIG=true
|
||||
update_grubcfg
|
||||
fi
|
||||
}
|
||||
|
||||
update_terminal_input() {
|
||||
local term_in=$1 && shift
|
||||
if grep -q "^GRUB_TERMINAL_INPUT=.*" ${grub_etc_default} ; then
|
||||
sed -i -e "s/^GRUB_TERMINAL_INPUT=.*/GRUB_TERMINAL_INPUT=${term_in}/" ${grub_etc_default}
|
||||
else
|
||||
echo GRUB_TERMINAL_INPUT=${term_in} >> ${grub_etc_default}
|
||||
fi
|
||||
RUN_MKCONFIG=true
|
||||
update_grubcfg
|
||||
}
|
||||
|
||||
update_terminal_output() {
|
||||
local term_out=$1 && shift
|
||||
if grep -q "^GRUB_TERMINAL_OUTPUT=.*" ${grub_etc_default} ; then
|
||||
sed -i -e "s/^GRUB_TERMINAL_OUTPUT=.*/GRUB_TERMINAL_OUTPUT=${term_out}/" ${grub_etc_default}
|
||||
else
|
||||
echo GRUB_TERMINAL_OUTPUT=${term_out} >> ${grub_etc_default}
|
||||
fi
|
||||
RUN_MKCONFIG=true
|
||||
update_grubcfg
|
||||
}
|
||||
|
||||
update_serial_command() {
|
||||
local serial_cmd=$1 && shift
|
||||
if grep -q "^GRUB_SERIAL_COMMAND=.*" ${grub_etc_default} ; then
|
||||
sed -i -e "s/^GRUB_SERIAL_COMMAND=.*/GRUB_SERIAL_COMMAND=${serial_cmd}/" ${grub_etc_default}
|
||||
else
|
||||
echo GRUB_SERIAL_COMMAND=${serial_cmd} >> ${grub_etc_default}
|
||||
fi
|
||||
RUN_MKCONFIG=true
|
||||
update_grubcfg
|
||||
}
|
||||
|
||||
set_default_bls() {
|
||||
local index=($(param_to_indexes "$1"))
|
||||
|
||||
@ -642,8 +701,13 @@ Usage: grubby [OPTION...]
|
||||
--make-default make the newly added entry the default boot entry
|
||||
--remove-args=STRING remove kernel arguments
|
||||
--remove-kernel=kernel-path remove all entries for the specified kernel
|
||||
--set-blscfg=value change value of GRUB_ENABLE_BLSCFG
|
||||
--set-default=kernel-path make the first entry referencing the specified kernel the default
|
||||
--set-default-index=entry-index make the given entry index the default entry
|
||||
--set-timeout=timeout change grub2 timeout value
|
||||
--serial-cmd=cmd set grub2 serial command
|
||||
--terminal-in=input-method set grub2 terminal input
|
||||
--terminal-out=output-method set grub2 terminal output
|
||||
--title=entry-title title to use for the new kernel entry
|
||||
--update-kernel=kernel-path updated information for the specified kernel
|
||||
--zipl configure zipl bootloader
|
||||
@ -658,8 +722,9 @@ EOF
|
||||
|
||||
OPTS="$(getopt -o hc:i:b:? --long help,add-kernel:,args:,bad-image-okay,\
|
||||
config-file:,copy-default,default-kernel,default-index,default-title,env:,\
|
||||
grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\
|
||||
remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\
|
||||
grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,remove-kernel:,\
|
||||
set-blscfg:,set-default:,set-default-index:,set-timeout:,\
|
||||
serial-cmd:,terminal-in:,terminal-out:,title:,update-kernel:,zipl,\
|
||||
bls-directory:,no-etc-grub-update,add-multiboot:,mbargs:,mounts:,boot-filesystem:,\
|
||||
bootloader-probe,debug,devtree,devtreedir:,elilo,efi,extlinux,grub,lilo,\
|
||||
output-file:,remove-mbargs:,remove-multiboot:,silo,yaboot -n ${SCRIPTNAME} -- "$@")"
|
||||
@ -732,6 +797,14 @@ while [ ${#} -gt 0 ]; do
|
||||
remove_kernel="${2}"
|
||||
shift
|
||||
;;
|
||||
--serial-cmd)
|
||||
serial_cmd="${2}"
|
||||
shift
|
||||
;;
|
||||
--set-blscfg)
|
||||
blscfg="${2}"
|
||||
shift
|
||||
;;
|
||||
--set-default)
|
||||
set_default="${2}"
|
||||
shift
|
||||
@ -740,6 +813,18 @@ while [ ${#} -gt 0 ]; do
|
||||
set_default="${2}"
|
||||
shift
|
||||
;;
|
||||
--set-timeout)
|
||||
timeout="${2}"
|
||||
shift
|
||||
;;
|
||||
--terminal-in)
|
||||
term_in="${2}"
|
||||
shift
|
||||
;;
|
||||
--terminal-out)
|
||||
term_out="${2}"
|
||||
shift
|
||||
;;
|
||||
--title)
|
||||
title="${2}"
|
||||
shift
|
||||
@ -820,6 +905,26 @@ if [[ -n $display_info ]]; then
|
||||
display_info_values "${display_info}"
|
||||
fi
|
||||
|
||||
if [[ -n $timeout ]]; then
|
||||
update_timeout "${timeout}"
|
||||
fi
|
||||
|
||||
if [[ -n $blscfg ]]; then
|
||||
update_blscfg "${blscfg}"
|
||||
fi
|
||||
|
||||
if [[ -n $term_in ]]; then
|
||||
update_terminal_input "${term_in}"
|
||||
fi
|
||||
|
||||
if [[ -n $term_out ]]; then
|
||||
update_terminal_output "${term_out}"
|
||||
fi
|
||||
|
||||
if [[ -n $serial_cmd ]]; then
|
||||
update_serial_command "${serial_cmd}"
|
||||
fi
|
||||
|
||||
remove_var_prefix "$(get_prefix)"
|
||||
|
||||
if [[ -n $kernel ]]; then
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
Name: grubby
|
||||
Version: 8.40
|
||||
Release: 83%{?dist}
|
||||
Release: 84%{?dist}
|
||||
Summary: Command line tool for updating bootloader configs
|
||||
License: GPL-2.0-or-later
|
||||
Source1: grubby-bls
|
||||
@ -74,6 +74,10 @@ fi
|
||||
%{_mandir}/man8/grubby.8*
|
||||
|
||||
%changelog
|
||||
* Mon Jul 20 2026 Marta Lewandowska <mlewando@redhat.com> - 8.40-84
|
||||
- Empower grubby to update the grub timeout and other values
|
||||
Resolves: RHEL-4341
|
||||
|
||||
* Wed Jul 30 2025 Leo Sandoval <lsandova@redhat.com> - 8.40-83
|
||||
- Update cfg when setting a default kernel
|
||||
Resolves:#RHEL-101784
|
||||
|
||||
Loading…
Reference in New Issue
Block a user