NetBSD/etc/powerd/scripts/sleep_button

48 lines
984 B
Bash
Executable File

#!/bin/sh -
#
# $NetBSD: sleep_button,v 1.5 2008/06/06 23:13:58 jmcneill Exp $
#
# Generic script for sleep button events.
#
# Arguments passed by powerd(8):
#
# device event
case "${2}" in
pressed)
/etc/rc.d/btdevctl stop
/etc/rc.d/btconfig stop
/etc/rc.d/ntpd stop
/etc/rc.d/dhclient stop
/etc/rc.d/network stop
/etc/rc.d/wpa_supplicant stop
if /sbin/sysctl machdep.sleep_state >/dev/null 2>&1; then
/sbin/sysctl -w machdep.sleep_state=3
else
sleep 1
if /etc/rc.d/apmd status >/dev/null ; then
/usr/sbin/apm -z
else
/usr/sbin/apm -d -z
fi
# ... waking up
sleep 1
fi
/etc/rc.d/wpa_supplicant start
/etc/rc.d/network start
/etc/rc.d/dhclient start
/etc/rc.d/ntpdate start
/etc/rc.d/ntpd start
/etc/rc.d/btconfig start
/etc/rc.d/btdevctl start
;;
released)
# Note that we don't really need to handle a released event here,
# so we can gracefully exit.
;;
*)
logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
exit 1
;;
esac