summaryrefslogtreecommitdiffstats
path: root/usr.sbin/zzz/zzz.sh
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2003-07-14 16:31:34 +0000
committernjl <njl@FreeBSD.org>2003-07-14 16:31:34 +0000
commit4c407178b613bf41b04646c28d7f4252c3caec75 (patch)
treed29fdcbf469851eeee8349ccb566783223345ca7 /usr.sbin/zzz/zzz.sh
parent22b2f1d3f09e2016e38a819cb2d51995e52a31c1 (diff)
downloadFreeBSD-src-4c407178b613bf41b04646c28d7f4252c3caec75.zip
FreeBSD-src-4c407178b613bf41b04646c28d7f4252c3caec75.tar.gz
Move the zzz utility to its own directory since it is no longer dependent
on apm(8)
Diffstat (limited to 'usr.sbin/zzz/zzz.sh')
-rw-r--r--usr.sbin/zzz/zzz.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/usr.sbin/zzz/zzz.sh b/usr.sbin/zzz/zzz.sh
new file mode 100644
index 0000000..7708153
--- /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
OpenPOWER on IntegriCloud