On Mon, Mar 07, 2005 at 09:22:07AM +0100, martin f krafft wrote:

> To prevent a user from upgrading a kernel and then suspending (the
> resume process would use the new kernel, which does not work), I am
> making the kernel-image drop /var/run/suspend2-new-kernel in place.
> This is cleaned during a successful reboot.
> 
> Could you please make hibernate refuse operation if this file
> exists? If it exists, tell the user to reboot!

Okay, should be possible.  I've written a trivial scriptlet to do
this, attached to this message.  I'll check with Bernard to see if
this is something he wants to incorporate upstream - standardising
these things between distros would be cool - but if not I'll
incorporate it as a Debian-specific addition.

I'll also add a suggests: to hibernate of kernel-patch-suspend2 ?

Cameron
# -*- 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
}

Attachment: signature.asc
Description: Digital signature

Reply via email to