Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / etc / powerd / scripts / sleep_button
blobe3be15024e948983906d4f2ad908ec241546ece8
1 #!/bin/sh -
3 # $NetBSD: sleep_button,v 1.4 2008/05/21 13:06:10 jmcneill Exp $
5 # Generic script for sleep button events.
7 # Arguments passed by powerd(8):
9 # device event
11 case "${2}" in
12 pressed)
13 /etc/rc.d/btdevctl stop
14 /etc/rc.d/btconfig stop
15 /etc/rc.d/ntpd stop
16 /etc/rc.d/dhclient stop
17 /etc/rc.d/network stop
18 /etc/rc.d/wpa_supplicant stop
19 if /sbin/sysctl machdep.sleep_state >/dev/null 2>&1; then
20 /sbin/sysctl -w machdep.sleep_state=3
21 else
22 sleep 1
23 if /etc/rc.d/apmd status >/dev/null ; then
24 /usr/sbin/apm -z
25 else
26 /usr/sbin/apm -d -z
28 # ... waking up
29 sleep 1
31 /etc/rc.d/wpa_supplicant start
32 /etc/rc.d/network start
33 /etc/rc.d/dhclient start
34 /etc/rc.d/ntpdate start
35 /etc/rc.d/ntpd start
36 /etc/rc.d/btconfig start
37 /etc/rc.d/btdevctl start
39 released)
40 # Note that we don't really need to handle a released event here,
41 # so we can gracefully exit.
44 logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
45 exit 1
47 esac