|
|
|
@ -197,7 +197,7 @@ param_to_indexes() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_prefix() {
|
|
|
|
|
if [[ $bootloader = grub2 ]] && grep -q /boot /proc/mounts; then
|
|
|
|
|
if [[ $bootloader = grub2 ]] && mountpoint -q /boot; then
|
|
|
|
|
echo "/boot"
|
|
|
|
|
else
|
|
|
|
|
echo ""
|
|
|
|
@ -218,8 +218,20 @@ expand_var() {
|
|
|
|
|
echo $var
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
has_kernelopts()
|
|
|
|
|
{
|
|
|
|
|
local args=${bls_options[$1]}
|
|
|
|
|
local opts=(${args})
|
|
|
|
|
|
|
|
|
|
for opt in ${opts[*]}; do
|
|
|
|
|
[[ $opt = "\$kernelopts" ]] && return 0
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_bls_args() {
|
|
|
|
|
local args=${bls_options[$i]}
|
|
|
|
|
local args=${bls_options[$1]}
|
|
|
|
|
local opts=(${args})
|
|
|
|
|
|
|
|
|
|
for opt in ${opts[*]}; do
|
|
|
|
@ -305,14 +317,26 @@ grub_class kernel${flavor}
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset_default_bls()
|
|
|
|
|
{
|
|
|
|
|
if [[ $bootloader = grub2 ]]; then
|
|
|
|
|
grub2-editenv "${env}" unset saved_entry
|
|
|
|
|
else
|
|
|
|
|
sed -i -e "/^default=.*/d" "${zipl_config}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
remove_bls_fragment() {
|
|
|
|
|
local indexes=($(param_to_indexes "$1"))
|
|
|
|
|
|
|
|
|
|
if [[ $indexes = "-1" ]]; then
|
|
|
|
|
print_error "The param $1 is incorrect"
|
|
|
|
|
print_error "The param $(get_prefix)$1 is incorrect"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
for i in "${indexes[@]}"; do
|
|
|
|
|
if [[ $default_index = $i ]]; then
|
|
|
|
|
unset_default_bls
|
|
|
|
|
fi
|
|
|
|
|
rm -f "${bls_file[$i]}"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
@ -456,20 +480,37 @@ update_args() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_bls_fragment() {
|
|
|
|
|
local param="$1"
|
|
|
|
|
local indexes=($(param_to_indexes "$1")) && shift
|
|
|
|
|
local remove_args=$1 && shift
|
|
|
|
|
local add_args=$1 && shift
|
|
|
|
|
local initrd=$1 && shift
|
|
|
|
|
local opts
|
|
|
|
|
|
|
|
|
|
if [[ $indexes = "-1" ]]; then
|
|
|
|
|
print_error "The param $1 is incorrect"
|
|
|
|
|
print_error "The param $(get_prefix)${param} is incorrect"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then
|
|
|
|
|
local old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
|
|
|
|
|
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
|
|
|
|
|
grub2-editenv "${env}" set kernelopts="${opts}"
|
|
|
|
|
elif [[ $bootloader = grub2 ]]; then
|
|
|
|
|
opts="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
for i in ${indexes[*]}; do
|
|
|
|
|
if [[ -n $remove_args || -n $add_args ]]; then
|
|
|
|
|
local old_args="$(get_bls_args "$i")"
|
|
|
|
|
local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
|
|
|
|
|
set_bls_value "${bls_file[$i]}" "options" "${new_args}"
|
|
|
|
|
|
|
|
|
|
if [[ $param != "ALL" || ! "$(has_kernelopts "$i")" ]]; then
|
|
|
|
|
set_bls_value "${bls_file[$i]}" "options" "${new_args}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $bootloader = grub2 && ! "$(has_kernelopts "$i")" && $opts = $new_args ]]; then
|
|
|
|
|
set_bls_value "${bls_file[$i]}" "options" "\$kernelopts"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ -n $initrd ]]; then
|
|
|
|
@ -693,6 +734,10 @@ while [ ${#} -gt 0 ]; do
|
|
|
|
|
shift
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [[ -z $update_kernel && -z $kernel ]] && [[ -n $args || -n $remove_args ]]; then
|
|
|
|
|
print_error "no action specified"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ -z $blsdir ]]; then
|
|
|
|
|
blsdir="/boot/loader/entries"
|
|
|
|
|
fi
|
|
|
|
|