opi5-efi/post.sh

27 lines
926 B
Bash
Raw Normal View History

2023-10-07 16:22:18 +00:00
#!/usr/bin/env bash
set -xeuf -o pipefail
UNAME_R="$(</boot/.uname)"
BOOT_PART="$(grep '/ ' /etc/fstab | awk '{print $1}')"
2023-10-08 08:00:58 +00:00
cp /opt/opi5-efi/boot.cmd "/boot/efi/boot.cmd"
cp /opt/opi5-efi/uEnv.txt "/boot/efi/uEnv.txt"
2023-10-07 16:22:18 +00:00
if [ ! -f /boot/.uname ]; then
echo "ERROR: No /boot/.uname found to extract 'uname -r' from."
exit 1
fi
2023-10-08 08:00:58 +00:00
if [ ! -f "/boot/initramfs-${UNAME_R}.img" ]; then
2023-10-08 06:43:34 +00:00
echo "Initramfs not found... regenerating."
2023-10-07 16:47:49 +00:00
/sbin/installkernel "${UNAME_R}" "/boot/.vmlinuz-${UNAME_R}-rpm" "/boot/.System.map-${UNAME_R}-rpm"
2023-10-08 08:00:58 +00:00
mv "/boot/vmlinuz-${UNAME_R}.old" "/boot/vmlinuz-${UNAME_R}"
2023-10-07 16:22:18 +00:00
fi
2023-10-08 08:00:58 +00:00
echo "rootdev=${BOOT_PART}" >> "/boot/efi/uEnv.txt"
sed -i "s/setenvrootdev/setenv rootdev \"${BOOT_PART}\"/" "/boot/efi/boot.cmd"
2023-10-07 16:22:18 +00:00
mkimage -A arm -T ramdisk -C none -n uInitrd -d "/boot/initramfs-${UNAME_R}.img" "/boot/uInitrd-${UNAME_R}"
2023-10-08 08:00:58 +00:00
mkimage -C none -A arm -T script -d "/boot/efi/boot.cmd" "/boot/efi/boot.scr"