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
|
#! /bin/sh -e
. /usr/share/debconf/confmodule
log () {
logger -t grub-installer "$@"
}
error () {
log "error: $@"
}
die () {
local template="$1"
shift
error "$@"
db_input critical "$template" || [ $? -eq 30 ]
db_go || true
exit 1
}
mountvirtfs () {
fstype="$1"
path="$2"
if grep -q "[[:space:]]$fstype\$" /proc/filesystems && \
! grep -q "^[^ ]\+ \+$path " /proc/mounts; then
mkdir -p "$path" || \
die grub-installer/mounterr "Error creating $path"
if mount -t "$fstype" "$fstype" "$path"; then
log "Success mounting $path"
trap "umount $path" HUP INT QUIT KILL PIPE TERM EXIT
elif [ "$fstype" = "efivarfs" ]; then
error "Error mounting $path (non-fatal)"
else
die grub-installer/mounterr "Error mounting $path"
fi
fi
}
# If we're installing grub-efi, it wants /sys mounted in the
# target. Maybe /proc too?
mountvirtfs proc /target/proc
mountvirtfs sysfs /target/sys
mountvirtfs efivarfs /target/sys/firmware/efi/efivars
grub-installer /target
|