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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#!/bin/sh
. /usr/share/debconf/confmodule
log() {
logger -t grub-installer "$@"
}
findfs () {
mount | grep "on /target${1%/} " | cut -d' ' -f1
}
findfstype () {
mount | grep "on /target${1%/} " | cut -d' ' -f5
}
ARCH="$(archdetect)"
case $ARCH in
i386/*)
MANUFACTURER="$(dmidecode -s system-manufacturer)"
case $MANUFACTURER in
Apple*)
# Note: depends on partman-efi to load the efivars module!
if [ -d /sys/firmware/efi ]; then
log "GRUB not yet usable on Intel-based Macs booted using EFI"
exit 1
fi
;;
esac
;;
esac
bootfs=$(findfs /boot)
[ -n "$bootfs" ] || bootfs="$(findfs /)"
if [ -z "$bootfs" ]; then
# Probably not yet mounted.
exit 0
fi
# Check for the control file to work around lvdisplay refusal to work with
# certian lvm device names.
if lvdisplay "$bootfs" | grep -q 'LV Name' 2>/dev/null || [ -e "$(dirname $bootfs)/control" ]; then
log "/boot is a lvm volume ($bootfs), cannot install grub"
exit 1
fi
bootfstype=$(findfstype /boot)
[ -n "$bootfstype" ] || bootfstype="$(findfstype /)"
if [ "$bootfstype" = "xfs" ]; then
log "/boot on xfs, unsafe to install grub"
# Check this first to allow for preseeding forcing grub to xfs.
db_get grub-installer/install_to_xfs
if [ "$RET" != true ]; then
# grub behaves erratically on xfs. If priority is such that the
# main menu is not being displayed, remove grub from the menu.
# If main menu is displayed, grub will be left on it so expert
# users can choose to use it.
db_get debconf/priority
if [ "$RET" != low ] && [ "$RET" != medium ]; then
exit 1
fi
fi
fi
db_get grub-installer/skip
if [ "$RET" = true ]; then
exit 1
fi
exit 0
|