#! /bin/sh
set -e

which update-m1n1 >/dev/null 2>&1 || exit 0

if [ ! -e /usr/lib/m1n1/m1n1.bin ] && [ -e /usr/lib/m1n1/boot.bin ]; then
	# looks like glanzmanns m1n1 package, not debians.
	exit 0
fi

set -- $DEB_MAINT_PARAMS
mode="${1#\'}"
mode="${mode%\'}"
case $0:$mode in
    # Only run on postinst configure and postrm remove, to avoid wasting
    # time by calling update-grub multiple times on upgrade and removal.
    # Also run if we have no DEB_MAINT_PARAMS, in order to work with old
    # kernel packages.
    */postinst.d/*:|*/postinst.d/*:configure|*/postrm.d/*:|*/postrm.d/*:remove)
	if [ -e /boot/efi/m1n1/boot.bin ]; then
		exec update-m1n1
	fi
	;;
esac

exit 0
