grubby-bls: only attempt to update cmdline if was already set

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2020-05-07 10:15:39 +02:00
parent 959c481fa9
commit 770392fcd0
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69

View File

@ -495,16 +495,20 @@ update_bls_fragment() {
if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then
local old_args="" local old_args=""
if [[ -z $no_etc_update ]]; then if [[ -z $no_etc_update ]] && [[ -e ${grub_etc_default} ]]; then
old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})"
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" if [[ -n $old_args ]]; then
opts=$(echo $opts | sed -e 's/\//\\\//g') opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}" opts="$(echo "$opts" | sed -e 's/\//\\\//g')"
sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}"
fi
fi fi
old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" if [[ -n $old_args ]]; then
grub2-editenv "${env}" set kernelopts="${opts}" opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
grub2-editenv "${env}" set kernelopts="${opts}"
fi
elif [[ $bootloader = grub2 ]]; then elif [[ $bootloader = grub2 ]]; then
opts="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" opts="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
fi fi