grubby-bls: expand kernel options if these are environment variables
The grub2 bootloader allows the BLS snippets fields to contain environment variables instead of constants. This is useful for example to define the kernel command line parameters only once in the grubenv file and set this variable in the BLS snippets. But this can be confusing for users when the information is printed by the grubby script, so expand the variables if they can be looked up in grubenv. Resolves: rhbz#1649785 Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
parent
4b1d63cacd
commit
b84a214b99
26
grubby-bls
26
grubby-bls
@ -216,6 +216,20 @@ get_prefix() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expand_var() {
|
||||||
|
local var=$1
|
||||||
|
|
||||||
|
if [[ $bootloader == "grub2" ]]; then
|
||||||
|
local value="$(grub2-editenv "${env}" list | grep ${var##$} | sed -e "s/${var##$}=//")"
|
||||||
|
value="$(echo ${value} | sed -e 's/\//\\\//g')"
|
||||||
|
if [[ -n $value ]]; then
|
||||||
|
var="$value"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $var
|
||||||
|
}
|
||||||
|
|
||||||
display_info_values() {
|
display_info_values() {
|
||||||
local indexes=($(param_to_indexes "$1"))
|
local indexes=($(param_to_indexes "$1"))
|
||||||
local prefix=$(get_prefix)
|
local prefix=$(get_prefix)
|
||||||
@ -226,9 +240,19 @@ display_info_values() {
|
|||||||
|
|
||||||
for i in ${indexes[*]}; do
|
for i in ${indexes[*]}; do
|
||||||
local root=""
|
local root=""
|
||||||
|
local value=""
|
||||||
local args=${bls_options[$i]}
|
local args=${bls_options[$i]}
|
||||||
local opts=(${args})
|
local opts=(${args})
|
||||||
|
|
||||||
|
for opt in ${opts[*]}; do
|
||||||
|
if [[ $opt =~ ^\$ ]]; then
|
||||||
|
value="$(expand_var $opt)"
|
||||||
|
args="$(echo ${args} | sed -e "s/${opt}/${value}/")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
local opts=(${args})
|
||||||
|
|
||||||
for opt in ${opts[*]}; do
|
for opt in ${opts[*]}; do
|
||||||
if echo $opt | grep -q "^root="; then
|
if echo $opt | grep -q "^root="; then
|
||||||
root="$(echo $opt | sed -e 's/root=//')"
|
root="$(echo $opt | sed -e 's/root=//')"
|
||||||
@ -443,7 +467,7 @@ update_args() {
|
|||||||
|
|
||||||
get_bls_args() {
|
get_bls_args() {
|
||||||
if [[ $bootloader = "grub2" && "${bls_options[$i]}" = "\$kernelopts" ]]; then
|
if [[ $bootloader = "grub2" && "${bls_options[$i]}" = "\$kernelopts" ]]; then
|
||||||
old_args=$(grub2-editenv list | grep kernelopts)
|
old_args=$(grub2-editenv "${env}" list | grep kernelopts)
|
||||||
old_args="${old_args##kernelopts=}"
|
old_args="${old_args##kernelopts=}"
|
||||||
else
|
else
|
||||||
old_args="${bls_options[$i]}"
|
old_args="${bls_options[$i]}"
|
||||||
|
Loading…
Reference in New Issue
Block a user