opi5-efi/post.sh

28 lines
972 B
Bash

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