-
Notifications
You must be signed in to change notification settings - Fork 72
/
mkosi.postinst
executable file
·38 lines (32 loc) · 1.37 KB
/
mkosi.postinst
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
#!/bin/bash -exu
# mkosi.postinst - Install compiled module into initramfs and fix grub.
# Use kernel with highest version.
KERNELRELEASE=$(ls -d /lib/modules/* | sort -V | tail -1)
KERNELRELEASE=${KERNELRELEASE##/lib/modules/}
# mkosi phase 2
#(We only support bios i.e. grub boot here).
if test -x /usr/bin/dracut; then
banner postinst >&2
# Register our module in kmod database.
depmod -a $KERNELRELEASE
# Install module into (and force its load early in) initrd.
# Add lkrg by default for any dracut invocation w/o requirement of
# passing '--force-drivers lkrg' command line option.
echo 'force_drivers+=" lkrg "' > /etc/dracut.conf.d/31-lkrg.conf
dracut --force /boot/initrd.img-$KERNELRELEASE $KERNELRELEASE
if [ -d /boot/loader/entries ]; then
# Install into systemd-boot loader.
# Because we pass INITRD argument to kernel-install, this will
# skip calling dracut (saving time, because it would regenerate
# ALL images) by mkosi hooks, but this will not delete old
# 'initrd' file from its boot entry, which is not big deal.
# Boot entry itself will not be duplicated.
kernel-install add $KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE /boot/initrd.img-$KERNELRELEASE
fi
if [ -e /etc/default/grub ]; then
# Delete default cmdline which contains 'quiet splash' to see full boot log.
sed -i /GRUB_CMDLINE_LINUX_DEFAULT/d /etc/default/grub
update-grub
fi
fi
exit 0