#!/bin/sh

set -e

. /usr/share/debconf/confmodule

case "${1}" in
	configure)
		db_get extlinux/install
		_INSTALL="${RET}" # boolean

		db_stop

		case "${_INSTALL}" in
			true)
				extlinux-update

				_DEVICE="$(df -P /boot/extlinux | tail -1 | awk '{ print $1 }' | sed -e 's|[0-9]||g')"

				extlinux-install "${_DEVICE}"
				;;

			*)
				if [ -x /etc/kernel/postinst.d/zz-extlinux ]
				then
					/etc/kernel/postinst.d/zz-extlinux
				fi
				;;
		esac
		;;

	abort-upgrade|abort-remove|abort-deconfigure)

		;;

	*)
		echo "postinst called with unknown argument \`${1}'" >&2
		exit 1
		;;
esac

#DEBHELPER#

exit 0
