There I was, out in the Big Horn Mountains, with a bunch of GPS data on my Toshiba Tecra 8000, collected with GPSDrive (http://www.gpsdrive.cc/). I had just upgraded from Fedora Core 1 to Fedora Core 2 (FC2). I decided to take a break and enjoy the mountains around me in peace and quiet. I hit the power button, which on many Toshibas puts the machine into RAM suspension. Which used to put this machine into RAM suspension. Oops, it shut down instead, loosing my data. Arrgh! Well! I started doing a bit of research on ACPI (http://acpi.sourceforge.net/), the power management system in FC2, and John Belmonte's extension for Toshiba laptops (http://memebeam.org/toys/ToshibaAcpiDriver). That and some emails on the Toshiba Linux List (http://linux.toshiba-dme.co.jp/linux/index.htm), and I was able to put together what I needed. This script comes with absolutely nothing, not even a guarantee to be useful for wrapping fish. There are two gotchas. * MySQL on FC2 does not want to suspend to ram. The workaround is to shut it down prior to suspension and restart it afterwards. This has the added advantage that it forces MySQL to flush to disk. * My USB floppy drive looses its marbles briefly after powerup, but recovers. One workaround would be to shut down the USB driver, as Belmonte does in the script from which I cribbed, but this works well enough for me. You need two files. In /etc/acpi/events, put the file power.button, which looks like so: -------------------------------------------------- # Power button instruction for ACPI. # Time-stamp: <2004-10-09 18:36:19 root power.button> event=button/power.* action=/etc/acpi/actions/power.button.sh -------------------------------------------------- Actually you can call it anything you want, as long as it isn't a hidden file (the file name has a period as its first letter). In /etc/acpi/actions/, put the script power.button.sh, which looks like so: -------------------------------------------------- # Run this script when the user hits the power button. # Time-stamp: <2004-10-09 19:04:16 root power.button.sh> # Check for hint to ignore power button. This is useful for wake from # suspend to RAM, etc. If we don't do this, the computer will cycle # through suspensions forever, or until it runs out of power. There # seems to be a debounce problem. From # http://memebeam.org/toys/ToshibaLibretto POWER_IGNORE=/var/run/ignore_powerbtn if [ -f $POWER_IGNORE ]; then rm -f $POWER_IGNORE exit 0 fi # MySQL-3.23.58-9 refuses to shut down. Well, we'll fix that! STATUS=`service mysqld status | grep -i running | cut -f1 -d' '` echo "mysqld status is: \"$STATUS\"" # If the daemon is running, we shut it down. if [ ! -z $STATUS ]; then echo "Shutting down mysqld." service mysqld stop while ! service mysqld status | grep -i stopped ; do echo "Waiting...." done fi sync # So we know to ignore this script on the way back up... touch /var/run/ignore_powerbtn sleep 1 # Do the deed... echo 3 > /proc/acpi/sleep sleep 4 if [ ! -z $STATUS ]; then echo "Firing up mysqld." service mysqld start # Spin until the daemon is running. while ! service mysqld status | grep -i running ; do echo "Waiting on MySQL Start...." done fi exit 0 -------------------------------------------------- Rename to a hidden file or delete the sample.conf file in /etc/acpi/events. To make the change effective, run "service acpid restart". -- Charles Curley /"\ ASCII Ribbon Campaign Looking for fine software \ / Respect for open standards and/or writing? X No HTML/RTF in email http://www.charlescurley.com / \ No M$ Word docs in email Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
Attachment:
pgpqqhoJ70Att.pgp
Description: PGP signature