51 lines
905 B
Bash
Executable File
51 lines
905 B
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Kernel hook for refind.
|
|
#
|
|
# Arguments passed to this script: $1 pkgname, $2 version.
|
|
#
|
|
PKGNAME="$1"
|
|
VERSION="$2"
|
|
|
|
. "${ROOTDIR}/etc/default/refind-kernel-hook.conf"
|
|
if [ "z$UPDATE_REFIND_CONF" != "z1" ]; then
|
|
exit 0;
|
|
fi
|
|
|
|
: ${REFIND_CONF:=boot/EFI/refind/refind.conf}
|
|
REFIND_CONF="${REFIND_CONF#/}"
|
|
|
|
mkdir -p "${REFIND_CONF%/*}"
|
|
touch "$REFIND_CONF"
|
|
|
|
tmpfile=$(mktemp /tmp/refind.XXXXXXX)
|
|
|
|
zversion=$(echo "$VERSION" | sed 's/[.]/[.]/g')
|
|
|
|
zentry=$(cat <<EOF
|
|
menuentry "Void Linux $VERSION" {
|
|
volume "Void Linux"
|
|
loader /vmlinuz-$VERSION
|
|
initrd /initramfs-$VERSION.img
|
|
options "$OPTIONS"
|
|
}
|
|
EOF
|
|
)
|
|
|
|
<"$REFIND_CONF" \
|
|
sed "/^menuentry \"Void Linux $zversion\" [{]\$/,/[}]/d" |
|
|
awk -v "entry=$zentry" '
|
|
/^timeout / {t=1}
|
|
/^menuentry / && !x {print entry; x=1}
|
|
1
|
|
END {
|
|
if (!x) {print entry}
|
|
if (!t) {print "timeout 20"}
|
|
}
|
|
' \
|
|
>"$tmpfile"
|
|
|
|
mv "$tmpfile" "$REFIND_CONF"
|
|
|
|
exit 0
|