add powermanagement and disk utils
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check for and abort a hibernate if the kernel indicates it has been
|
||||
# updated, as we will be completly unable to resume.
|
||||
if [ "$1" = "hibernate" ] && [ -f "/run/do-not-hibernate" ]; then
|
||||
echo "kernel update inhibits hibernate (/run/do-not-hibernate present)"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# Launch plymouth daemon if necessary
|
||||
|
||||
. "${PM_FUNCTIONS}"
|
||||
|
||||
# Fail if no plymouthd
|
||||
command_exists plymouthd || exit $NA
|
||||
|
||||
# Check for splash parameter in /proc/cmdline
|
||||
grep -qw "splash" /proc/cmdline || exit $NA
|
||||
|
||||
launch_plymouthd()
|
||||
{
|
||||
/sbin/plymouthd --mode=suspend
|
||||
return 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
hibernate|suspend)
|
||||
launch_plymouthd
|
||||
;;
|
||||
*) exit $NA
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
# vim:noexpandtab
|
||||
#
|
||||
# Author: Till Maas <opensource till name>
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
source "${PM_FUNCTIONS}"
|
||||
source /etc/pm/config.d/hd-apm-restore.conf
|
||||
|
||||
HD_APM_DEVICES=""
|
||||
for udi in $(hal-find-by-capability --capability storage)
|
||||
do
|
||||
drive_type=$(hal-get-property --udi "${udi}" --key storage.drive_type)
|
||||
if [ "${drive_type}" == "disk" ]
|
||||
then
|
||||
HD_APM_DEVICES+="$(hal-get-property --udi "${udi}" --key block.device | sed 's,^/dev/,,') "
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
case "$1" in
|
||||
hibernate|suspend)
|
||||
for DEVICE in ${HD_APM_DEVICES}
|
||||
do
|
||||
HD_APM_FEATURE=$(hdparm -I "/dev/${DEVICE}" | grep "Advanced Power Management feature set")
|
||||
if [[ "${HD_APM_FEATURE}" != "" ]]
|
||||
then
|
||||
if (echo "${HD_APM_FEATURE}" | grep -q "*" )
|
||||
then
|
||||
HD_APM_LEVEL=$(hdparm -I "/dev/${DEVICE}" | grep "Advanced power management level" | cut -d" " -f 5)
|
||||
else
|
||||
HD_APM_LEVEL=255
|
||||
fi
|
||||
if [[ "${HD_APM_LEVEL}" != "unknown" ]]
|
||||
then
|
||||
echo "saving level ${HD_APM_LEVEL} for device ${DEVICE}"
|
||||
savestate "${DEVICE}" "${HD_APM_LEVEL}"
|
||||
else
|
||||
echo "Advanced Power Management value of device ${DEVICE} unknown"
|
||||
fi
|
||||
else
|
||||
echo "Advanced Power Management not supported by device ${DEVICE}."
|
||||
fi
|
||||
done
|
||||
;;
|
||||
thaw|resume)
|
||||
for DEVICE in ${HD_APM_DEVICES}
|
||||
do
|
||||
HD_APM_LEVEL=$(restorestate "${DEVICE}")
|
||||
if [[ "${HD_APM_LEVEL}" != "" ]]
|
||||
then
|
||||
echo "restoring level ${HD_APM_LEVEL} for device ${DEVICE}"
|
||||
hdparm -B "${HD_APM_LEVEL}" "/dev/${DEVICE}"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $?
|
||||
@@ -0,0 +1,26 @@
|
||||
Index: pm-utils-1.4.1/pm/module.d/uswsusp
|
||||
===================================================================
|
||||
--- pm-utils-1.4.1.orig/pm/module.d/uswsusp
|
||||
+++ pm-utils-1.4.1/pm/module.d/uswsusp
|
||||
@@ -82,6 +82,7 @@ fi
|
||||
if [ -z "$HIBERNATE_MODULE" ] && \
|
||||
[ -f /sys/power/disk ] && \
|
||||
grep -q disk /sys/power/state && \
|
||||
+ grep -q "resume=" /proc/cmdline && \
|
||||
[ -c /dev/snapshot ] &&
|
||||
command_exists s2disk; then
|
||||
HIBERNATE_MODULE="uswsusp"
|
||||
Index: pm-utils-1.4.1/pm/pm-functions.in
|
||||
===================================================================
|
||||
--- pm-utils-1.4.1.orig/pm/pm-functions.in
|
||||
+++ pm-utils-1.4.1/pm/pm-functions.in
|
||||
@@ -306,7 +306,8 @@ fi
|
||||
|
||||
if [ -z "$HIBERNATE_MODULE" ] && \
|
||||
[ -f /sys/power/disk ] && \
|
||||
- grep -q disk /sys/power/state; then
|
||||
+ grep -q disk /sys/power/state && \
|
||||
+ grep -q "resume=" /proc/cmdline; then
|
||||
HIBERNATE_MODULE="kernel"
|
||||
do_hibernate()
|
||||
{
|
||||
@@ -0,0 +1,99 @@
|
||||
Index: pm-utils-1.4.1/configure.ac
|
||||
===================================================================
|
||||
--- pm-utils-1.4.1.orig/configure.ac
|
||||
+++ pm-utils-1.4.1/configure.ac
|
||||
@@ -41,7 +41,6 @@ man/Makefile
|
||||
src/Makefile
|
||||
pm/Makefile
|
||||
pm/sleep.d/Makefile
|
||||
-pm/power.d/Makefile
|
||||
pm/module.d/Makefile
|
||||
])
|
||||
|
||||
Index: pm-utils-1.4.1/man/Makefile.am
|
||||
===================================================================
|
||||
--- pm-utils-1.4.1.orig/man/Makefile.am
|
||||
+++ pm-utils-1.4.1/man/Makefile.am
|
||||
@@ -2,7 +2,6 @@ pm_mans = \
|
||||
on_ac_power.1 \
|
||||
pm-is-supported.1 \
|
||||
pm-pmu.8 \
|
||||
- pm-powersave.8 \
|
||||
pm-action.8
|
||||
|
||||
if HAVE_XMLTO
|
||||
@@ -13,7 +12,6 @@ EXTRA_DIST = \
|
||||
on_ac_power.xml \
|
||||
pm-pmu.xml \
|
||||
pm-is-supported.xml \
|
||||
- pm-powersave.xml \
|
||||
pm-action.xml \
|
||||
$(pm_mans)
|
||||
|
||||
Index: pm-utils-1.4.1/pm/sleep.d/Makefile.am
|
||||
===================================================================
|
||||
--- pm-utils-1.4.1.orig/pm/sleep.d/Makefile.am
|
||||
+++ pm-utils-1.4.1/pm/sleep.d/Makefile.am
|
||||
@@ -2,8 +2,7 @@ sleepdir = $(libdir)/pm-utils/sleep.d
|
||||
|
||||
sleep_SCRIPTS = \
|
||||
00logging \
|
||||
- 00powersave \
|
||||
- 01grub \
|
||||
+ 01grub \
|
||||
49bluetooth \
|
||||
55NetworkManager \
|
||||
75modules \
|
||||
Index: pm-utils-1.4.1/pm/Makefile.am
|
||||
===================================================================
|
||||
--- pm-utils-1.4.1.orig/pm/Makefile.am
|
||||
+++ pm-utils-1.4.1/pm/Makefile.am
|
||||
@@ -1,6 +1,5 @@
|
||||
SUBDIRS = \
|
||||
sleep.d \
|
||||
- power.d \
|
||||
module.d
|
||||
|
||||
pm_libdir = $(libdir)/pm-utils
|
||||
Index: pm-utils-1.4.1/pm/HOWTO.hooks
|
||||
===================================================================
|
||||
--- pm-utils-1.4.1.orig/pm/HOWTO.hooks
|
||||
+++ pm-utils-1.4.1/pm/HOWTO.hooks
|
||||
@@ -24,12 +24,6 @@ The actual sleep method being used will
|
||||
if your hook needs to handle suspend-hybrid (or any other platform-specific
|
||||
sleep method), it should examine the second parameter.
|
||||
|
||||
-For hooks in power.d, the potential values of that parameter are:
|
||||
-true -- the hook MUST perform whatever action is appropriate when the system
|
||||
- transitions TO battery power.
|
||||
-false -- The hook MUST perform whatever action is appropriate when the system
|
||||
- transitions FROM battery power.
|
||||
-
|
||||
NAMING SCHEME
|
||||
|
||||
All hooks are run in lexical sort order according to the C locale.
|
||||
@@ -44,8 +38,7 @@ Any other return code is interpreted by
|
||||
from the hook that it should abort whatever it is doing. When running sleep.d
|
||||
hooks, that means that pm-utils stops running hooks, aborts the suspend/resume
|
||||
process, calls any hooks that ran successfully prior to this one with the
|
||||
-appropriate wakeup options, and exits with a non-zero exit code. When running
|
||||
-power.d hooks, any hooks after this one will be skipped.
|
||||
+appropriate wakeup options, and exits with a non-zero exit code.
|
||||
|
||||
SLEEP.D SPECIFIC NOTES
|
||||
|
||||
Index: pm-utils-1.4.1/src/Makefile.am
|
||||
===================================================================
|
||||
--- pm-utils-1.4.1.orig/src/Makefile.am
|
||||
+++ pm-utils-1.4.1/src/Makefile.am
|
||||
@@ -16,9 +16,7 @@ bin_SCRIPTS = pm-is-supported
|
||||
|
||||
dist_bin_SCRIPTS = on_ac_power
|
||||
|
||||
-sbin_SCRIPTS = pm-powersave
|
||||
-
|
||||
-script_in_files = pm-action.in pm-is-supported.in pm-powersave.in service
|
||||
+script_in_files = pm-action.in pm-is-supported.in service
|
||||
|
||||
CLEANFILES = $(script_in_files:.in=)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# Config file for hd-apm-restore hook
|
||||
|
||||
# Devices, where the hd apm value should be restored, separated by space
|
||||
#HD_APM_DEVICES="sda"
|
||||
|
||||
# Use this to overwrite a value for a device in case hdparm reports
|
||||
# "unknown value" for the apm level. This is ignored when hdparm
|
||||
# returns an other value.
|
||||
#savestate sda 192
|
||||
#savestate sdb 192
|
||||
#savestate sdc 192
|
||||
#savestate sdd 192
|
||||
Reference in New Issue
Block a user