void-packages/srcpkgs/grub/files/kernel.d/grub.post

32 lines
771 B
Plaintext
Raw Normal View History

2011-07-10 00:03:36 +02:00
#!/bin/sh
#
# Kernel hook for GRUB 2.
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"
VERSION="$2"
[ -r /boot/grub/grub.cfg ] \
&& groot=$(awk '/^set root=/{print substr($2, 8, 3); exit}' \
/boot/grub/grub.cfg)
[ -e /boot/grub/device.map ] && [ -n "${groot}" ] \
&& dev=$(awk "/${groot}/{ print \$NF}" /boot/grub/device.map)
if [ -n "${dev}" -a -r "${dev}" ]; then
dd if="${dev}" bs=512 skip=0 count=1 2>/dev/null|grep -q GRUB
[ $? -eq 0 ] && grub_installed=1
fi
if [ -n "${dev}" -a -z "$grub_installed" ]; then
echo "WARNING: GRUB2 has not been installed into ${dev}."
echo "WARNING: please run 'grub-install ${dev}'."
fi
if command -v grub-mkconfig >/dev/null 2>&1; then
grub-mkconfig -o /boot/grub/grub.cfg
exit $?
fi
exit 0