#!/bin/sh
#
# Record that we have a suspend/hibernate in progress.
#
. "${PM_FUNCTIONS}"

LOGFILE="/var/lib/pm-utils/status"

# Check for and abort a hibernate if the kernel indicates it has been
# updated, as we will be completly unable to resume.  LP: #350491.
case "$1" in
	hibernate)
		if [ -f '/var/run/do-not-hibernate' ]; then
			echo "kernel update inhibits hibernate (/var/run/do-not-hibernate present)"
			exit 1
		fi
	;;
esac

# Record the current operation to allow failure detection.
case "$1" in
	hibernate|suspend)
		echo "$1" >"$LOGFILE"
		;;
	thaw|resume) 
		rm -f "$LOGFILE"
		;;
esac
