# -*- sh -*-
# vim:ft=sh:ts=8:sw=4:noet

AddConfigHandler LILOConfigOptions
AddConfigHelp "EnsureLILOResumes <boolean>" "Makes sure that LILO boots the correct kernel image when rebooting to resume. This is useful when you boot into a non-default kernel or want to avoid LILO's menu delay when resuming."

DoLILOHack() {
    [ x"$ENSURE_LILO_RESUMES" != "x1" ] && return 0
    image=`sed -e 's/^.*BOOT_IMAGE=\([^ ]\+\).*$/\1/' < /proc/cmdline`
    vecho 2 "Setting LILO boot-once image to $image"
    lilo -R $image && return 0
    vecho 0 "lilo -R failed with exit status $?."
    return 1
}

LILOConfigOptions() {
    case $1 in
	ensureliloresumes)
	    BoolIsOn "$1" "$2" && ENSURE_LILO_RESUMES=1 || return 0
	    ;;
	*)
	    return 1
    esac
    if [ -z "$LILO_HOOKED" ] ; then
	AddSuspendHook 92 DoLILOHack
	LILO_HOOKED=1
    fi
    return 0
}

# $Id: lilo 1196 2008-05-01 11:58:52Z nigel $
