forked from hetzneronline/installimage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblsconfig.functions.sh
44 lines (36 loc) · 950 Bytes
/
blsconfig.functions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
#
# blsconfig functions
#
# (c) 2023, Hetzner Online GmbH
#
blsconfig_fix_paths() {
# paths must be relative to the "boot partition"!
# try to find boot mount
local boot_mp='/boot'
while read _ mp _; do
[[ "$mp" == "$FOLD/hdd/boot" ]] && boot_mp=''
done < /proc/mounts
# adjust linux and initrd options for all entries
for f in "$FOLD/hdd/boot/loader/entries/"*'.conf'; do
[[ -e "$f" ]] || continue
{
while read option first_arg remaining_args; do
case "$option" in
linux|initrd)
first_arg="$boot_mp/${first_arg##*/}"
;;
esac
echo "$option $first_arg $remaining_args" | awk '{$1=$1};1'
done < "$f"
} > "$f.new"
if cmp -s "$f.new" "$f"; then
rm "$f.new"
continue
fi
debug '# adjusting BLS config paths:'
diff -Naur "$f" "$f.new" | debugoutput
mv "$f.new" "$f"
done
}
# vim: ai:ts=2:sw=2:et