summaryrefslogtreecommitdiff
path: root/usr.sbin/zzz
diff options
context:
space:
mode:
authorNate Lawson <njl@FreeBSD.org>2003-07-14 16:31:34 +0000
committerNate Lawson <njl@FreeBSD.org>2003-07-14 16:31:34 +0000
commit035e325c81b75ea3b5c878c55cc133672b6ac06d (patch)
treed29fdcbf469851eeee8349ccb566783223345ca7 /usr.sbin/zzz
parent6545508362480900d24d2d7e39b5a2c538ae7a03 (diff)
downloadsrc-test2-035e325c81b75ea3b5c878c55cc133672b6ac06d.tar.gz
src-test2-035e325c81b75ea3b5c878c55cc133672b6ac06d.zip
Move the zzz utility to its own directory since it is no longer dependent
on apm(8)
Notes
Notes: svn path=/head/; revision=117557
Diffstat (limited to 'usr.sbin/zzz')
-rw-r--r--usr.sbin/zzz/Makefile6
-rw-r--r--usr.sbin/zzz/zzz.855
-rw-r--r--usr.sbin/zzz/zzz.sh43
3 files changed, 104 insertions, 0 deletions
diff --git a/usr.sbin/zzz/Makefile b/usr.sbin/zzz/Makefile
new file mode 100644
index 000000000000..8c4a9beb763a
--- /dev/null
+++ b/usr.sbin/zzz/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+SCRIPTS=zzz.sh
+MAN= zzz.8
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/zzz/zzz.8 b/usr.sbin/zzz/zzz.8
new file mode 100644
index 000000000000..4258f62b6e7b
--- /dev/null
+++ b/usr.sbin/zzz/zzz.8
@@ -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
diff --git a/usr.sbin/zzz/zzz.sh b/usr.sbin/zzz/zzz.sh
new file mode 100644
index 000000000000..770815358109
--- /dev/null
+++ b/usr.sbin/zzz/zzz.sh
@@ -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