#!/bin/sh

set -e

action=$1
version=$2

# debconf
. /usr/share/debconf/confmodule
db_version 2.0

isfresh=0
have_to_run=0

if [ ! -f /etc/lilo.conf ]; then
	isfresh=1
	db_text high lilo/new-config || true
	db_go
else
	# Check for deprecated PATH. Bug#267538
	if grep -q "^bitmap=/usr/share/lilo/contrib" /etc/lilo.conf; then
		db_beginblock
		db_text high lilo/bad_bitmap || true
		db_endblock
		db_go
	fi

	if grep -q "^[[:space:]]*large-memory" /etc/lilo.conf; then
		db_set lilo/add_large_memory false
	else
		db_beginblock
		db_text high lilo/add_large_memory || true
		db_endblock
		db_go

		db_get lilo/add_large_memory || true;
		if [ x"$RET" = x"true" ]; then
			have_to_run=1
		fi
	fi
fi

if [ x"$isfresh" = x"0" ]; then
	if [ -e /boot/boot.b ]; then	
		have_to_run=1
		db_beginblock
		db_text high lilo/upgrade || true
		db_endblock
		db_go
	fi
fi

#db_set lilo/runme = false

if [ x"$have_to_run" != x"0" ]; then
	db_beginblock	
 	db_input high lilo/runme || true
	db_endblock
	db_go
fi

exit 0
