#!/bin/sh PATH=/sbin:/usr/sbin:/bin:/usr/bin suspend_scripts=`ls -1 /etc/apm/event.d/* | egrep -v "(.dpkg-[a-z]*|~|.bak)$" | sort | grep -v laptop-net` resume_scripts=`ls -1 /etc/apm/event.d/* | egrep -v "(.dpkg-[a-z]*|~|.bak)$" | grep -v laptop-net | sort -r` # Suspend sub systems. for x in $suspend_scripts ; do test -x "$x" && sh "$x" suspend done # Stop network. test -x /etc/init.d/laptop-net && /etc/init.d/laptop-net stop # Stop apache. test -x /etc/init.d/apache && /etc/init.d/apache stop killall -KILL /usr/sbin/apache # Save the system clock to the hardware clock. test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop # Do suspend. sleep 2 sync sync sleep 2 if [ -f /proc/swsusp/activate ]; then echo > /proc/swsusp/activate else echo "1 0 0" > /proc/sys/kernel/swsusp fi sleep 2 # Recover the system clock based on the hardware clock. test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start # Start apache. test -x /etc/init.d/apache && /etc/init.d/apache start # Start network. test -x /etc/init.d/laptop-net && /etc/init.d/laptop-net start # Resume sub systems. for x in $resume_scripts ; do test -x "$x" && sh "$x" resume done