Skip to content
Snippets Groups Projects
Commit 1567e3b5 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

update

parent a0685316
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
# Mirror: https://github.com/recolic/shared-bootdir-helper
pkgname=shared-bootdir-helper
pkgver=1.0
pkgver=1.1
pkgrel=1
pkgdesc="Allow multiple linux installations to share the same /boot directory, even with different kernel parameters. "
url="https://git.recolic.net/root/$pkgname"
......
# You use this placeholder in GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub
placeholder="__KERNEL_PARAMETER_MANAGED_BY_HELPER"
# mapping between hostname and kernel parameters.
declare -A map_hostname_to_kparam=(
# Parameters can not contain `|` character, which will crash this naive script.
# hostname MUST be in lowercase, because `hook-kernel-rename.sh` converts hostname to lowercase.
# kernel parameters MUST at least contain `root=xxx rw` to make kernel working.
# This is some examples:
["recolicpc"]="quiet amdgpu.ppfeaturemask=0xffffffff cryptdevice=/dev/disk/by-id/nvme-SAMSUNG_MZVLW256HEHP-xxxxxxxxxxxx:cryptlvm:allow-discards cryptkey=/dev/disk/by-partlabel/xxxxxxxx:0:64 crypto=:aes-xts-plain64:512:0:"
["recolicmpc"]="quiet cryptdevice=/dev/disk/by-id/ata-SAMSUNG_MZNTY128HDHP-000xxxxxxxxxx:cryptlvm:allow-discards cryptkey=/dev/disk/by-partlabel/xxxxxxx:0:64 crypto=:aes-xts-plain64:512:0: resume=/dev/RecolicmpcVolGroup/swap"
["recolicmsmpc"]="quiet cryptdevice=/dev/disk/by-id/xxxxxxxxxxxxxxxxxx:cryptlvm cryptkey=/dev/disk/by-partlabel/xxxxxxxx:0:64 crypto=xxxxxxxxxxxxxxxxxxxxxx"
["recolicpc"]="root=/dev/mapper/RecolicpcVolGroup-root rw quiet amdgpu.ppfeaturemask=0xffffffff cryptdevice=/dev/disk/by-id/nvme-SAMSUNG_MZVLW256HEHP-xxxxxxxxxxxx:cryptlvm:allow-discards cryptkey=/dev/disk/by-partlabel/xxxxxxxx:0:64 crypto=:aes-xts-plain64:512:0:"
["recolicmpc"]="root=/dev/mapper/RecolicmpcVolGroup-root rw quiet cryptdevice=/dev/disk/by-id/ata-SAMSUNG_MZNTY128HDHP-000xxxxxxxxxx:cryptlvm:allow-discards cryptkey=/dev/disk/by-partlabel/xxxxxxx:0:64 crypto=:aes-xts-plain64:512:0: resume=/dev/RecolicmpcVolGroup/swap"
["recolicmsmpc"]="root=/dev/mapper/RecolicmsmpcVolGroup-root rw quiet cryptdevice=/dev/disk/by-id/xxxxxxxxxxxxxxxxxx:cryptlvm cryptkey=/dev/disk/by-partlabel/xxxxxxxx:0:64 crypto=xxxxxxxxxxxxxxxxxxxxxx"
)
......@@ -10,6 +10,8 @@
# to correct kernel parameters.
#
# Usage: ./this.sh /boot/grub/grub.cfg
#
# Note that grub.cfg must be auto-generated, to make its format correct.
source "/etc/shared-bootdir-helper-multi-kparam.cfg" || exit 1
......@@ -20,23 +22,20 @@ inputfile="$1"
while IFS= read -r line; do
matched=0
if [[ "$line" == *"$placeholder"* ]]; then
if [[ "$line" == *"\tlinux\t/"* ]]; then
for hostname in "${!map_hostname_to_kparam[@]}"; do
# Assuming that, the kimg filename contains "vmlinuz-xxx-$hostname ", in lowercase. That's important!
[[ "$line" == *"-$hostname "* ]] &&
echo "$line" | sed "s|$placeholder|${map_kimage_to_kparam[$hostname]}|g" >> "$tmpfile" &&
echo "$line" | sed "s|-$hostname .*$|-$hostname ${map_kimage_to_kparam[$hostname]}|g" >> "$tmpfile" &&
matched=1 &&
break
done
[[ $matched == 0 ]] && echo "Warning: kernel line '$line' doesnt match ANY entry in /etc/shared-bootdir-helper-multi-kparam.cfg" && exit 2
fi
[[ $matched == 0 ]] && echo "$line" >> "$tmpfile"
done < "$inputfile" || exit $?
mv "$tmpfile" "$inputfile" || exit $?
grep "$placeholder" "$inputfile" &&
echo "Warning: placeholder '$placeholder' still exists in processed grub.cfg. Have you correctly set the 'map_kimage_to_kparam' of $0? Please double-check! " &&
exit 2
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment