NetBSD/etc/powerd/scripts/sleep_button

56 lines
1.0 KiB
Bash
Executable File

#!/bin/sh -
#
# $NetBSD: sleep_button,v 1.10 2011/10/17 23:27:41 jmcneill Exp $
#
# Generic script for sleep button events.
#
# Arguments passed by powerd(8):
#
# device event
case "${2}" in
pressed)
/etc/rc.d/bluetooth 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 -q hw.acpi.sleep.state; then
/sbin/sysctl -w hw.acpi.sleep.state=3
elif /sbin/sysctl -q machdep.xen.suspend; then
/sbin/sysctl -w machdep.xen.suspend=1
else
sleep 1
if /etc/rc.d/apmd onestatus >/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/bluetooth start
;;
released)
case "${1}" in
vmt0)
# Virtual machine is resuming, restart the network
/etc/rc.d/dhcpcd restart
;;
esac
;;
*)
logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
exit 1
;;
esac