home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
rescue
/
usr
/
lib
/
hal
/
scripts
/
linux
/
hal-system-power-hibernate-linux
< prev
next >
Wrap
Text File
|
2006-11-29
|
2KB
|
77 lines
#!/bin/sh
POWERSAVED_SUSPEND2DISK="dbus-send --system --dest=com.novell.powersave \
--print-reply /com/novell/powersave \
com.novell.powersave.action.SuspendToDisk"
unsupported() {
echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
echo No hibernate script found >&2
exit 1
}
#Mandriva support suspend-scripts
if [ -f /etc/mandriva-release ] ; then
if [ -x /usr/sbin/pmsuspend ] ; then
/usr/sbin/pmsuspend disk
RET=$?
else
unsupported
fi
#RedHat/Fedora only support pm-utils
elif [ -f /etc/redhat-release ] || [ -f /etc/fedora-release ] || [ -x /usr/sbin/pm-hibernate ] ; then
if [ -x /usr/sbin/pm-hibernate ] ; then
/usr/sbin/pm-hibernate
RET=$?
else
unsupported
fi
#SuSE and ALTLinux only support powersave
elif [ -f /etc/altlinux-release ] || [ -f "/etc/SuSE-release" ] ; then
if [ -x /usr/bin/powersave ] ; then
$POWERSAVED_SUSPEND2DISK
RET=$?
else
unsupported
fi
#Other distros just need to have *any* tools installed
else
if [ -x "/usr/bin/powersave" ] ; then
$POWERSAVED_SUSPEND2DISK
RET=$?
elif [ -x "/usr/sbin/pmi" ] ; then
/usr/sbin/pmi action hibernate force
RET=$?
elif [ -x "/usr/sbin/pm-hibernate" ] ; then
/usr/sbin/pm-hibernate
RET=$?
elif [ -x "/usr/sbin/hibernate" ] ; then
# Suspend2 tools installed
/usr/sbin/hibernate --force
RET=$?
elif [ -w "/sys/power/state" ] ; then
# Use the raw kernel sysfs interface
echo "disk" > /sys/power/state
RET=$?
else
unsupported
fi
fi
#Refresh devices as a resume can do funny things
for type in button battery ac_adapter
do
devices=`hal-find-by-capability --capability $type`
for device in $devices
do
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
$device org.freedesktop.Hal.Device.Rescan
done
done
exit $RET