10696600cSBjoern A. Zeeb#!/bin/sh 20696600cSBjoern A. Zeeb# 30696600cSBjoern A. Zeeb# Copyright (c) 1999 Mitsuru IWASAKI 40696600cSBjoern A. Zeeb# All rights reserved. 50696600cSBjoern A. Zeeb# 60696600cSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without 70696600cSBjoern A. Zeeb# modification, are permitted provided that the following conditions 80696600cSBjoern A. Zeeb# are met: 90696600cSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright 100696600cSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer. 110696600cSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright 120696600cSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer in the 130696600cSBjoern A. Zeeb# documentation and/or other materials provided with the distribution. 140696600cSBjoern A. Zeeb# 150696600cSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 160696600cSBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 170696600cSBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 180696600cSBjoern A. Zeeb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 190696600cSBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 200696600cSBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 210696600cSBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 220696600cSBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 230696600cSBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 240696600cSBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 250696600cSBjoern A. Zeeb# SUCH DAMAGE. 260696600cSBjoern A. Zeeb# 270696600cSBjoern A. Zeeb# $FreeBSD$ 280696600cSBjoern A. Zeeb# 290696600cSBjoern A. Zeeb 300696600cSBjoern A. Zeeb# sample run command file for APM Suspend Event 310696600cSBjoern A. Zeeb 320696600cSBjoern A. Zeebif [ $# -ne 2 ]; then 330696600cSBjoern A. Zeeb echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]" 340696600cSBjoern A. Zeeb exit 1 350696600cSBjoern A. Zeebfi 360696600cSBjoern A. Zeeb 370696600cSBjoern A. Zeebsubsystem=$1 380696600cSBjoern A. Zeebstate=$2 390696600cSBjoern A. Zeeb 400696600cSBjoern A. Zeebif [ -r /var/run/rc.suspend.pid ]; then 410696600cSBjoern A. Zeeb exit 1 420696600cSBjoern A. Zeebfi 430696600cSBjoern A. Zeeb 440696600cSBjoern A. Zeebecho $$ 2> /dev/null > /var/run/rc.suspend.pid 450696600cSBjoern A. Zeeb 460696600cSBjoern A. Zeeb# If a device driver has problems suspending, try unloading it before 470696600cSBjoern A. Zeeb# suspend and reloading it on resume. Example: 480696600cSBjoern A. Zeeb# kldunload usb 490696600cSBjoern A. Zeeb 50*2cf8ef59SJohannes Totz. /etc/rc.subr 51*2cf8ef59SJohannes Totz 52*2cf8ef59SJohannes Totzload_rc_config 53*2cf8ef59SJohannes Totz 54*2cf8ef59SJohannes Totzrcorder_opts="-k suspend" 55*2cf8ef59SJohannes Totz 56*2cf8ef59SJohannes Totzcase ${local_startup} in 57*2cf8ef59SJohannes Totz[Nn][Oo] | '') ;; 58*2cf8ef59SJohannes Totz*) find_local_scripts_new ;; 59*2cf8ef59SJohannes Totzesac 60*2cf8ef59SJohannes Totz 61*2cf8ef59SJohannes Totzfiles=`rcorder ${rcorder_opts} /etc/rc.d/* ${local_rc} 2>/dev/null` 62*2cf8ef59SJohannes Totz 63*2cf8ef59SJohannes Totzfor _rc_elem in $files; do 64*2cf8ef59SJohannes Totz debug "run_rc_script $_rc_elem suspend" 65*2cf8ef59SJohannes Totz run_rc_script $_rc_elem suspend 66*2cf8ef59SJohannes Totzdone 67*2cf8ef59SJohannes Totz 680696600cSBjoern A. Zeeb/usr/bin/logger -t $subsystem suspend at `/bin/date +'%Y%m%d %H:%M:%S'` 690696600cSBjoern A. Zeeb/bin/sync && /bin/sync && /bin/sync 700696600cSBjoern A. Zeeb/bin/sleep 3 710696600cSBjoern A. Zeeb 720696600cSBjoern A. Zeeb/bin/rm -f /var/run/rc.suspend.pid 730696600cSBjoern A. Zeebif [ $subsystem = "apm" ]; then 740696600cSBjoern A. Zeeb /usr/sbin/zzz 750696600cSBjoern A. Zeebelse 760696600cSBjoern A. Zeeb # Notify the kernel to continue the suspend process 770696600cSBjoern A. Zeeb /usr/sbin/acpiconf -k 0 780696600cSBjoern A. Zeebfi 790696600cSBjoern A. Zeeb 800696600cSBjoern A. Zeebexit 0 81