sleep_button revision 1.10
11.1Smycroft#!/bin/sh - 21.1Smycroft# 31.10Sjmcneill# $NetBSD: sleep_button,v 1.10 2011/10/17 23:27:41 jmcneill Exp $ 41.1Smycroft# 51.3Sjmcneill# Generic script for sleep button events. 61.1Smycroft# 71.1Smycroft# Arguments passed by powerd(8): 81.1Smycroft# 91.1Smycroft# device event 101.1Smycroft 111.1Smycroftcase "${2}" in 121.3Sjmcneillpressed) 131.7Sjruoho 141.8Splunky /etc/rc.d/bluetooth stop 151.3Sjmcneill /etc/rc.d/ntpd stop 161.3Sjmcneill /etc/rc.d/dhclient stop 171.3Sjmcneill /etc/rc.d/network stop 181.4Sjmcneill /etc/rc.d/wpa_supplicant stop 191.7Sjruoho 201.9Sjym if /sbin/sysctl -q hw.acpi.sleep.state; then 211.7Sjruoho /sbin/sysctl -w hw.acpi.sleep.state=3 221.9Sjym elif /sbin/sysctl -q machdep.xen.suspend; then 231.9Sjym /sbin/sysctl -w machdep.xen.suspend=1 241.3Sjmcneill else 251.4Sjmcneill sleep 1 261.6Sabs if /etc/rc.d/apmd onestatus >/dev/null ; then 271.4Sjmcneill /usr/sbin/apm -z 281.4Sjmcneill else 291.4Sjmcneill /usr/sbin/apm -d -z 301.4Sjmcneill fi 311.4Sjmcneill # ... waking up 321.4Sjmcneill sleep 1 331.3Sjmcneill fi 341.7Sjruoho 351.4Sjmcneill /etc/rc.d/wpa_supplicant start 361.3Sjmcneill /etc/rc.d/network start 371.3Sjmcneill /etc/rc.d/dhclient start 381.3Sjmcneill /etc/rc.d/ntpdate start 391.3Sjmcneill /etc/rc.d/ntpd start 401.8Splunky /etc/rc.d/bluetooth start 411.3Sjmcneill ;; 421.7Sjruoho 431.3Sjmcneillreleased) 441.10Sjmcneill case "${1}" in 451.10Sjmcneill vmt0) 461.10Sjmcneill # Virtual machine is resuming, restart the network 471.10Sjmcneill /etc/rc.d/dhcpcd restart 481.10Sjmcneill ;; 491.10Sjmcneill esac 501.3Sjmcneill ;; 511.1Smycroft*) 521.3Sjmcneill logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1 531.1Smycroft exit 1 541.1Smycroft ;; 551.1Smycroftesac 56