rc.suspend revision 180620
148734Siwasaki#!/bin/sh 248734Siwasaki# 366830Sobrien# Copyright (c) 1999 Mitsuru IWASAKI 466830Sobrien# All rights reserved. 566830Sobrien# 666830Sobrien# Redistribution and use in source and binary forms, with or without 766830Sobrien# modification, are permitted provided that the following conditions 866830Sobrien# are met: 966830Sobrien# 1. Redistributions of source code must retain the above copyright 1066830Sobrien# notice, this list of conditions and the following disclaimer. 1166830Sobrien# 2. Redistributions in binary form must reproduce the above copyright 1266830Sobrien# notice, this list of conditions and the following disclaimer in the 1366830Sobrien# documentation and/or other materials provided with the distribution. 1466830Sobrien# 1566830Sobrien# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1666830Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1766830Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1866830Sobrien# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1966830Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2066830Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2166830Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2266830Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2366830Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2466830Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2566830Sobrien# SUCH DAMAGE. 2666830Sobrien# 2750472Speter# $FreeBSD: head/etc/rc.suspend 180620 2008-07-19 20:12:33Z marcel $ 2848734Siwasaki# 2966830Sobrien 3048734Siwasaki# sample run command file for APM Suspend Event 3148734Siwasaki 32124001Snjlif [ $# -ne 2 ]; then 33170976Snjl echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]" 34124001Snjl exit 1 35124001Snjlfi 36124001Snjl 37124001Snjlsubsystem=$1 38124001Snjlstate=$2 39124001Snjl 4051231Ssheldonhif [ -r /var/run/rc.suspend.pid ]; then 4148734Siwasaki exit 1 4248734Siwasakifi 4348734Siwasaki 44124766Snjlecho $$ 2> /dev/null > /var/run/rc.suspend.pid 4548734Siwasaki 4648734Siwasaki# If you have troubles on suspending with PC-CARD modem, try this. 4748734Siwasaki# See also contrib/pccardq.c (Only for PAO users). 48180620Smarcel# pccardq | awk -F '~' '$5 == "filled" && $4 ~ /uart/ \ 4948734Siwasaki# { printf("pccardc power %d 0", $1); }' | sh 5048734Siwasaki 51170976Snjl# If a device driver has problems suspending, try unloading it before 52170976Snjl# suspend and reloading it on resume. Example: 53124001Snjl# kldunload usb 54124001Snjl 55124001Snjllogger -t $subsystem suspend at `date +'%Y%m%d %H:%M:%S'` 5648734Siwasakisync && sync && sync 57170976Snjlsleep 3 5848734Siwasaki 5948734Siwasakirm -f /var/run/rc.suspend.pid 60170976Snjlif [ $subsystem = "apm" ]; then 61170976Snjl /usr/sbin/zzz 62170976Snjlelse 63170976Snjl # Notify the kernel to continue the suspend process 64170976Snjl /usr/sbin/acpiconf -k 0 65170976Snjlfi 6648734Siwasaki 6748734Siwasakiexit 0 68