#!/bin/bash set -x speedstep() { cpu="$1" speed="$2" if [ "$speed" = "max" ]; then cat "$1/speed-max" > "$1/speed"; fi if [ "$speed" = "min" ]; then cat "$1/speed-min" > "$1/speed"; fi } speedstep_all() { if [ -d /proc/sys/cpu ]; then for d in /proc/sys/cpu/*; do speedstep "$d" "$1" done fi } ac="no" if apm |grep -q on-line &>/dev/null; then ac="yes"; fi NETS="eth0 eth1" RESTARTS_SERVICES="named irda ypbind smb postfix apache ntpd" case "$1" in standby|suspend) killall -CONT kupdated sync for if in $NETS; do ifdown $if & done cardctl suspend cardctl eject 2 ;; resume) if test "$ac" = "no"; then sync killall -STOP kupdated fi cardctl eject 2; sleep 2 cardctl insert 2 cardctl resume for if in $NETS; do ifup $if done for s in $RESTART_SERVICES; do /sbin/service $s condrestart & done ;; change) case "$2" in power) # Power condition change if test "$ac" = "yes"; then speedstep_all max sync killall -CONT kupdated /root/apm_suspend_control --cancel else speedstep_all min killall -CONT kupdated sync killall -STOP kupdated fi ;; battery) # Battery low. if test "$ac" = no; then sync /root/apm_suspend_control --suspend& fi ;; esac ;; esac