summarylogtreecommitdiffstats
path: root/dracut-install
blob: 01fd0921775497a9885bd47a5f61391aa8c63b13 (plain)
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
#!/bin/bash -e

kernels=()
dracut_update=0

while read -r line; do
    if [[ $line != 'usr/lib/modules/'+([^/])'/pkgbase' ]]; then
		dracut_update=1 # Dracut files have been updated
        continue 
    fi

    read -r pkgbase < "/${line}"
	kernels+=("${pkgbase}")
done

if (( dracut_update )); then
	kernels=()
	for file in /lib/modules/*/pkgbase; do
		if read -r pkgbase &> /dev/null < "$file"; then
			kernels+=("${pkgbase}")
		fi
	done
fi

for kernel in "${kernels[@]}"; do
	path="$(grep -lE "^${kernel}\$" /usr/lib/modules/*/pkgbase)"
	version=$(basename "${path%/pkgbase}")
    read -r pkgbase < "$path"

    install -Dm0644 "/${path%'/pkgbase'}/vmlinuz" "/boot/vmlinuz-${pkgbase}"

	echo ":: Building initramfs for $kernel-$version"
	dracut -f --hostonly --no-early-microcode --no-hostonly-cmdline "/boot/initramfs-${kernel}.img" --kver "${version}"  #Exclude microcode added explicit flag
	echo ":: Building fallback initramfs for $kernel-$version"
	dracut -f --no-hostonly --no-early-microcode "/boot/initramfs-${kernel}-fallback.img" --kver "${version}" #Exclude microcode
done