Move the zzz utility to its own directory since it is no longer dependent

on apm(8)
This commit is contained in:
Nate Lawson 2003-07-14 16:31:34 +00:00
parent 6545508362
commit 035e325c81
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=117557
3 changed files with 104 additions and 0 deletions

6
usr.sbin/zzz/Makefile Normal file
View File

@ -0,0 +1,6 @@
# $FreeBSD$
SCRIPTS=zzz.sh
MAN= zzz.8
.include <bsd.prog.mk>

55
usr.sbin/zzz/zzz.8 Normal file
View File

@ -0,0 +1,55 @@
.\" Copyright (c) 2003 Nate Lawson
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd July 13, 2003
.Dt ZZZ 8
.Os
.Sh NAME
.Nm zzz
.Nd suspend an ACPI or APM system
.Sh SYNOPSIS
.Nm
.Sh DESCRIPTION
The
.Nm
utility
checks for ACPI or APM support and then suspends the system appropriately.
For APM,
.Pp
.Dl apm -z
.Pp
will be issued.
For ACPI, the configured suspend state will be looked up, checked to see
if it is supported, and
.Pp
.Dl acpiconf -s <state>
.Pp
will be issued.
.Sh SEE ALSO
.Xr acpiconf 8 ,
.Xr apm 8 ,
.Xr acpi 4 ,
.Xr apm 4

43
usr.sbin/zzz/zzz.sh Normal file
View File

@ -0,0 +1,43 @@
#!/bin/sh
#
# Suspend the system using either ACPI or APM.
# For APM, "apm -z" will be issued.
# For ACPI, the configured suspend state will be looked up, checked to see
# if it is supported, and "acpiconf -s <state>" will be issued.
#
# Mark Santcroos <marks@ripe.net>
#
# $FreeBSD$
PATH=/sbin:/usr/sbin:/usr/bin:/bin
ACPI_SUSPEND_STATE=hw.acpi.suspend_state
ACPI_SUPPORTED_STATES=hw.acpi.supported_sleep_state
APM_SUSPEND_DELAY=machdep.apm_suspend_delay
# Check for ACPI support
if sysctl $ACPI_SUSPEND_STATE >/dev/null 2>&1; then
# Get configured suspend state
SUSPEND_STATE=`sysctl $ACPI_SUSPEND_STATE | sed 's|^.*: S||'`
# Get list of supported suspend states
SUPPORTED_STATES=`sysctl $ACPI_SUPPORTED_STATES | sed 's|^.*: ||'`
# Check if the configured suspend state is supported by the system
if echo $SUPPORTED_STATES | grep S$SUSPEND_STATE >/dev/null; then
# execute ACPI style suspend command
exec acpiconf -s $SUSPEND_STATE
else
echo -n "Requested suspend state S$ACPI_SUSPEND_STATE "
echo -n "is not supported. "
echo "Supported states: $ACPI_SUPPORTED_STATES"
fi
# Check for APM support
elif sysctl $APM_SUSPEND_DELAY >/dev/null 2>&1; then
# Execute APM style suspend command
exec apm -z
else
echo "Error: no ACPI or APM suspend support found."
fi
exit 1