Index: hibernate.sh
===================================================================
--- hibernate.sh	(revision 1186)
+++ hibernate.sh	(working copy)
@@ -783,6 +783,7 @@
 	local new_CHAIN_UP_TO
 	new_CHAIN_UP_TO="`awk \"BEGIN{print substr(\\\"$bit\\\", 1, 2)}\"`" || break
 	[ -n "$new_CHAIN_UP_TO" ] && CHAIN_UP_TO=$new_CHAIN_UP_TO || continue
+	[ -n "$POST_HIBERNATE_ONLY" ] && continue
 	bit=${bit##$CHAIN_UP_TO}
 	vecho 1 "$EXE: [$CHAIN_UP_TO] Executing $bit ... "
 	[ -n "$OPT_DRY_RUN" ] && continue
@@ -884,7 +885,7 @@
 # Use -x if we're being really verbose!
 [ $VERBOSITY -ge 4 ] && set -x
 
-echo "Starting suspend at "`date` | $LOGPIPE > /dev/null
+[ -z "$POST_HIBERNATE_ONLY" ] && echo "Starting suspend at "`date` | $LOGPIPE > /dev/null
 
 EXIT_CODE=0
 
@@ -911,7 +912,8 @@
 
 PluginTermination
 
-echo "Resumed at "`date` | $LOGPIPE > /dev/null
+#[ -z "$PRE_HIBERNATE_ONLY" ] && echo "Resumed at "`date` | $LOGPIPE > /dev/null
+echo "Exited with result $EXIT_CODE at "`date` | $LOGPIPE > /dev/null
 
 exit $EXIT_CODE
 
Index: scriptlets.d/suspend2
===================================================================
--- scriptlets.d/suspend2	(revision 1186)
+++ scriptlets.d/suspend2	(working copy)
@@ -13,6 +13,12 @@
 AddLongOption "reboot::"
 AddOptionHelp "-r[0|1], --reboot[=<0|1>] (requires UseSuspend2 on)" "If 0 is specified, disables rebooting after suspend, regardless of the Reboot option in the configuration file. If 1 or omitted, will force a reboot after suspending."
 
+AddLongOption "pre-hibernate-only::"
+AddOptionHelp "--pre-hibernate-only (requires UseSuspend2 on)" "If set, the hibernate script will exit after running all commands up to but excluding the command to actually start the hibernation. This can be used with TuxOnice's post 3.0-rc6 pre_hibernate_command setting, to provide improved transparent replacement of swsusp."
+
+AddLongOption "post-hibernate-only::"
+AddOptionHelp "--post-hibernate-only (requires UseSuspend2 on)" "If set, the hibernate script will only run commands that would normally be run after returning from hibernating. This can be used with TuxOnice's post 3.0-rc6 post_hibernate_command setting, to provide improved transparent replacement of swsusp."
+
 AddConfigHelp "EnableEscape <boolean> (requires UseSuspend2 on)" "If specified, allows (or disallows) the use of the escape key to abort a suspend. If this line is not specified, the Escape key's behaviour is unchanged."
 
 AddConfigHelp "DefaultConsoleLevel <N> (requires UseSuspend2 on)" "If specified, sets the default console level. 0 gives a progress bar. 1 gives a progress bar with numbers. 2 or higher give increasing amounts of debugging. If this line is not specified, the default console level is unchanged."
@@ -80,7 +86,7 @@
     # Detect where suspend2 is these days.
     if [ -d "/sys/power/tuxonice/" ] ; then
 	SWSUSP_ROOT="/sys/power/tuxonice"
-	FILEWRITER_SIGNATURE="TuxOnIce"
+	FILEWRITER_SIGNATURE="7cMC6ZhW5Qw="
     elif [ -d "/sys/power/suspend2/" ] ; then
 	SWSUSP_ROOT="/sys/power/suspend2"
     elif [ -d "/proc/swsusp/" ] ; then
@@ -141,6 +147,12 @@
 	-n|--no-suspend)
 	    SWSUSP2_NO_SUSPEND=1
 	    ;;
+	--pre-hibernate-only)
+	    PRE_HIBERNATE_ONLY=1
+	    ;;
+	--post-hibernate-only)
+	    POST_HIBERNATE_ONLY=1
+	    ;;
 	--save-settings)
 	    if [ -n "$2" ] ; then
 		SWSUSP2_SAVE_SETTINGS_FILE="$2"
@@ -443,6 +455,9 @@
 
 DoSwsusp2() {
     local error
+    if [ -n "$PRE_HIBERNATE_ONLY" ] ; then
+	    exit 0
+    fi
     if [ -n "$SWSUSP2_BUG_REPORT" ] ; then
 	# Dump our debug info now.
 	vecho 0 "System information follows. (Please include with bug reports)."
@@ -783,7 +798,7 @@
 	    # We're good to go.
 	    vecho 1 "$EXE: Detected filewriter image ready for use."
 	    ;;
-	Suspend2|TuxOnIce)
+	Suspend2|TuxOnIce|7cMC6ZhW5Qw=)
 	    # Eeek! This is an incompatible image
 	    # reliably preserve the starting block.
 	    vecho 1 "$EXE: Killing incompatible filewriter image."
