File apcupsd-pm-utils.patch of Package apcupsd

--- platforms/apccontrol.in
+++ platforms/apccontrol.in
@@ -20,7 +20,7 @@
 
 APCPID=@PIDDIR@/apcupsd.pid
 APCUPSD=@sbindir@/apcupsd
-HIBERNATE="/usr/bin/systemctl hibernate"
+HIBERNATE=/usr/sbin/pm-hibernate
 SHUTDOWN=@SHUTDOWN@
 SCRIPTSHELL=@SCRIPTSHELL@
 SCRIPTDIR=@sysconfdir@
--- README.SUSE
+++ README.SUSE
@@ -1,22 +1,14 @@
 Advanced apcupsd configuration
 
 
-WARNING for hybrid sleep (suspend to both)
-
-Hybrid sleep works properly only on human operated desktop systems.
-
-Do not use hybrid sleep on machines that need to automatically turn on
-after power outage! If the power returns while the computer sleeps but
-before battery goes out of power, the UPS has no way to wake the device.
-
-
 Suspend to disk
 
 If you want to configure nut to do suspend to disk instead of shutdown
 you should:
 
+- You need pm-utils package installed.
 - Verify, that suspend to disk works correctly on your machine,
-  e. g. by systemctl hibernate
+  e. g. by pm-hibernate
   (You can lose your unsaved data, if your computer does not hibernate
   correctly.)
 - Verify, that your UPS provides reasonable grace period to complete
--- apcupsd.hibernate
+++ apcupsd.hibernate
@@ -1,15 +1,24 @@
 #!/bin/bash
 
+. $PM_UTILS_LIBDIR/functions
 
-# Always stop apcupsd before sleep, but do not initiate powerdown for hybrid-sleep.
-if [ "$1" = pre ] && ( [ "$2" = hibernate ] || [ "$2" = hybrid-sleep ] ) ; then
-	/sbin/service apcupsd.service stop
-fi
-if [ "$1" = pre ] && [ "$2" = hibernate ] ; then
-	# FIXME: All hibernate quirks are called in parallel. To be on a safest side, we should initiate powerdown grace period when they terminate.
-	sleep 5
-	/etc/apcupsd/apccontrol killpower
-fi
-if [ "$1" = post ] && ( [ "$2" = hibernate ] || [ "$2" = hybrid-sleep ] ) ; then
-	/sbin/service apcupsd.service start
-fi
+case "$1" in
+	hibernate)
+		if test -f @PWRFAILDIR@/powerfail ; then
+			/etc/init.d/apcupsd stop
+			# Stopping of daemon typically needs at least 3 sec.
+			sleep 10
+			/etc/init.d/apcupsd powerdown
+		fi
+		;;
+	thaw)
+		# powerfail exists => apcupsd was running before hibernation
+		if test -f @PWRFAILDIR@/powerfail ; then
+			/etc/init.d/apcupsd start
+		fi
+		;;
+	*)
+		;;
+esac
+
+exit 0