MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /usr/share/hal/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/hal/scripts/hal-system-power-suspend
#!/bin/sh

POWERSAVED_SUSPEND2RAM="dbus-send --system --dest=com.novell.powersave \
                        --print-reply /com/novell/powersave \
                        com.novell.powersave.action.SuspendToRam"

alarm_not_supported() {
	echo org.freedesktop.Hal.Device.SystemPowerManagement.AlarmNotSupported >&2
	echo Waking the system up is not supported >&2
	exit 1
}

unsupported() {
	echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
	echo No suspend method found >&2
	exit 1
}

read seconds_to_sleep

#PMU systems cannot use /sys/power/state yet, so use a helper to issue an ioctl
if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" == "pmu" ]; then
	hal-system-power-pmu sleep
	if [ $? -ne 0 ]; then
		echo "org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported" >&2
		exit 1
	fi
	exit 0
fi

#SuSE and ALTLinux only support powersave
if [ -f "/etc/altlinux-release" ] || [ -f "/etc/SuSE-release" ] ; then
	if [ -x /usr/bin/powersave ] ; then
	        $POWERSAVED_SUSPEND2RAM
		RET=$?
	else
		# TODO: add support
		unsupported
	fi

#RedHat/Fedora only support pm-utils
elif [ -f "/etc/redhat-release" ] || [ -f "/etc/fedora-release" ] ; then
	# TODO: fix pm-suspend to take a --wakeup-alarm argument
	if [ $seconds_to_sleep != "0" ] ; then
		alarm_not_supported
	fi
	# TODO: fixup pm-suspend to define erroc code (see alarm above) and throw
	#	   the appropriate exception
	if [ -x "/usr/sbin/pm-suspend" ] ; then
		/usr/sbin/pm-suspend
		RET=$?
	else
		# TODO: add support
		unsupported
	fi

#Other distros just need to have *any* tools installed
else
	if [ -x "/usr/bin/powersave" ] ; then
	    $POWERSAVED_SUSPEND2RAM
	    RET=$?
	elif [ -x "/usr/sbin/pmi" ] ; then
	    /usr/sbin/pmi action suspend force
	    RET=$?
	elif [ -w "/sys/power/state" ] ; then
	    # Use the raw kernel sysfs interface
	    echo "mem" > /sys/power/state
	    RET=$?
	else
	    # TODO: add other scripts support
	    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

Anon7 - 2021