# -*- sh -*-
# vim:ft=sh:ts=8:sw=4:noet
#
# newkernel scriptlet - suggested by Martin F Krafft (madduck), and
# written by Cameron Patrick.  Based (very loosely) on the lockfile
# scriptlet.

NEWKERNELFILE="/var/run/suspend2-new-kernel"

AddSuspendHook 01 NewKernelFileCheck

# Check to see if $NEWKERNELFILE exists, and if so print a message and
# refuse to hibernate.
NewKernelFileCheck() {
    if ! [ -f "$NEWKERNELFILE" ]; then
	return 0 # no file present, so go ahead and hibernate
    fi
    vecho 0 "$EXE: You have upgraded your kernel, and a suspend image from this"
    vecho 0 "$EXE: kernel will not resume correctly with the new one.  Please"
    vecho 0 "$EXE: reboot your machine before suspending again."
    vecho 0 ""
    vecho 0 "$EXE: If you think this message is incorrect, or you know what you're"
    vecho 0 "$EXE: doing and want to suspend anyway, please remove $NEWKERNELFILE"
    return 2 # refuse to hibernate, even with -f
}

