Skip to content

Commit

Permalink
Merge commit 'a86c1f8e0fd2546f27f6fc607b5d77613c23e73a'
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Sep 8, 2023
2 parents a0a0e61 + a86c1f8 commit 25a8308
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scripts/lib/require.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ function require_systemd_kernel_parameter() {
local new_kernel_parameter=${1:?"new parameter required"}

for configuration in /boot/loader/entries/*.conf; do
echo
message 'systemd-boot' "updating $configuration"
message 'systemd-boot' "$(grep kernel_parameters "$configuration")"
echo
message 'systemd-boot' "$(grep options "$configuration")"

case "$new_kernel_parameter" in
+*)
Expand All @@ -279,7 +281,9 @@ function require_systemd_kernel_parameter() {
;;
esac

message 'systemd-boot' "$(grep kernel_parameters "$configuration")"
message 'systemd-boot' "$(grep options "$configuration")"
echo
echo
done
}

Expand All @@ -289,7 +293,7 @@ function _add_systemd_kernel_parameter() {

local kernel_paramters
declare -a kernel_paramters
IFS=' ' read -ra kernel_paramters <<<"$(grep kernel_paramters "$configuration")"
IFS=' ' read -ra kernel_paramters <<<"$(grep options "$configuration")"

local output
output=$(echo -n "current kernel_paramters: |")
Expand All @@ -304,7 +308,7 @@ function _add_systemd_kernel_parameter() {
done
kernel_paramters+=("$new_kernel_parameter")

sudo sed -i -e "s|^kernel_paramters.*$|${kernel_paramters[*]}|" "$configuration"
sudo sed -i -e "s|^options.*$|${kernel_paramters[*]}|" "$configuration"
}

function _remove_systemd_kernel_parameter() {
Expand All @@ -313,7 +317,7 @@ function _remove_systemd_kernel_parameter() {

local kernel_paramters
declare -a kernel_paramters
IFS=' ' read -ra kernel_paramters <<<"$(grep kernel_paramters "$configuration")"
IFS=' ' read -ra kernel_paramters <<<"$(grep options "$configuration")"

local output
output=$(echo -n "current kernel_paramters: |")
Expand All @@ -329,6 +333,6 @@ function _remove_systemd_kernel_parameter() {
done

if [ "$found" -eq 1 ]; then
sudo sed -i -e "s|^kernel_paramters.*$|${kernel_paramters[*]}|" "$configuration"
sudo sed -i -e "s|^options.*$|${kernel_paramters[*]}|" "$configuration"
fi
}

0 comments on commit 25a8308

Please sign in to comment.