xref: /freebsd/libexec/rc/rc.suspend (revision 0696600c41600d80bcd993bfd8e675d0ae6951fe)
1*0696600cSBjoern A. Zeeb#!/bin/sh
2*0696600cSBjoern A. Zeeb#
3*0696600cSBjoern A. Zeeb# Copyright (c) 1999  Mitsuru IWASAKI
4*0696600cSBjoern A. Zeeb# All rights reserved.
5*0696600cSBjoern A. Zeeb#
6*0696600cSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without
7*0696600cSBjoern A. Zeeb# modification, are permitted provided that the following conditions
8*0696600cSBjoern A. Zeeb# are met:
9*0696600cSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright
10*0696600cSBjoern A. Zeeb#    notice, this list of conditions and the following disclaimer.
11*0696600cSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright
12*0696600cSBjoern A. Zeeb#    notice, this list of conditions and the following disclaimer in the
13*0696600cSBjoern A. Zeeb#    documentation and/or other materials provided with the distribution.
14*0696600cSBjoern A. Zeeb#
15*0696600cSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16*0696600cSBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*0696600cSBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*0696600cSBjoern A. Zeeb# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19*0696600cSBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*0696600cSBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*0696600cSBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*0696600cSBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*0696600cSBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*0696600cSBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*0696600cSBjoern A. Zeeb# SUCH DAMAGE.
26*0696600cSBjoern A. Zeeb#
27*0696600cSBjoern A. Zeeb# $FreeBSD$
28*0696600cSBjoern A. Zeeb#
29*0696600cSBjoern A. Zeeb
30*0696600cSBjoern A. Zeeb# sample run command file for APM Suspend Event
31*0696600cSBjoern A. Zeeb
32*0696600cSBjoern A. Zeebif [ $# -ne 2 ]; then
33*0696600cSBjoern A. Zeeb	echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]"
34*0696600cSBjoern A. Zeeb	exit 1
35*0696600cSBjoern A. Zeebfi
36*0696600cSBjoern A. Zeeb
37*0696600cSBjoern A. Zeebsubsystem=$1
38*0696600cSBjoern A. Zeebstate=$2
39*0696600cSBjoern A. Zeeb
40*0696600cSBjoern A. Zeebif [ -r /var/run/rc.suspend.pid ]; then
41*0696600cSBjoern A. Zeeb	exit 1
42*0696600cSBjoern A. Zeebfi
43*0696600cSBjoern A. Zeeb
44*0696600cSBjoern A. Zeebecho $$ 2> /dev/null > /var/run/rc.suspend.pid
45*0696600cSBjoern A. Zeeb
46*0696600cSBjoern A. Zeeb# If you have troubles on suspending with PC-CARD modem, try this.
47*0696600cSBjoern A. Zeeb# See also contrib/pccardq.c (Only for PAO users).
48*0696600cSBjoern A. Zeeb# pccardq | awk -F '~' '$5 == "filled" && $4 ~ /uart/ \
49*0696600cSBjoern A. Zeeb#	{ printf("pccardc power %d 0", $1); }' | sh
50*0696600cSBjoern A. Zeeb
51*0696600cSBjoern A. Zeeb# If a device driver has problems suspending, try unloading it before
52*0696600cSBjoern A. Zeeb# suspend and reloading it on resume.  Example:
53*0696600cSBjoern A. Zeeb# kldunload usb
54*0696600cSBjoern A. Zeeb
55*0696600cSBjoern A. Zeeb/usr/bin/logger -t $subsystem suspend at `/bin/date +'%Y%m%d %H:%M:%S'`
56*0696600cSBjoern A. Zeeb/bin/sync && /bin/sync && /bin/sync
57*0696600cSBjoern A. Zeeb/bin/sleep 3
58*0696600cSBjoern A. Zeeb
59*0696600cSBjoern A. Zeeb/bin/rm -f /var/run/rc.suspend.pid
60*0696600cSBjoern A. Zeebif [ $subsystem = "apm" ]; then
61*0696600cSBjoern A. Zeeb	/usr/sbin/zzz
62*0696600cSBjoern A. Zeebelse
63*0696600cSBjoern A. Zeeb	# Notify the kernel to continue the suspend process
64*0696600cSBjoern A. Zeeb	/usr/sbin/acpiconf -k 0
65*0696600cSBjoern A. Zeebfi
66*0696600cSBjoern A. Zeeb
67*0696600cSBjoern A. Zeebexit 0
68