]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/zzz/zzz.sh
zfs: merge openzfs/zfs@0ee9b0239
[FreeBSD/FreeBSD.git] / usr.sbin / zzz / zzz.sh
1 #!/bin/sh
2 #
3 # Suspend the system using either ACPI or APM.
4 # For APM, "apm -z" will be issued.
5 # For ACPI, the configured suspend state will be looked up, checked to see
6 # if it is supported, and "acpiconf -s <state>" will be issued.
7 #
8 # Mark Santcroos <marks@ripe.net>
9 #
10
11 PATH=/sbin:/usr/sbin:/usr/bin:/bin
12
13 ACPI_SUSPEND_STATE=hw.acpi.suspend_state
14 ACPI_SUPPORTED_STATES=hw.acpi.supported_sleep_state
15 APM_SUSPEND_DELAY=machdep.apm_suspend_delay
16
17 # Check for ACPI support
18 if sysctl $ACPI_SUSPEND_STATE >/dev/null 2>&1; then
19         # Get configured suspend state
20         SUSPEND_STATE=$(sysctl -n $ACPI_SUSPEND_STATE)
21
22         # Get list of supported suspend states
23         SUPPORTED_STATES=$(sysctl -n $ACPI_SUPPORTED_STATES)
24
25         # Check if the configured suspend state is supported by the system
26         if echo "$SUPPORTED_STATES" | grep "$SUSPEND_STATE" >/dev/null; then
27                 # execute ACPI style suspend command
28                 exec acpiconf -s "$SUSPEND_STATE"
29         else
30                 echo -n "Requested suspend state $SUSPEND_STATE "
31                 echo -n "is not supported."
32                 echo    "Supported states: $SUPPORTED_STATES"
33         fi
34 # Check for APM support
35 elif sysctl $APM_SUSPEND_DELAY >/dev/null 2>&1; then
36         # Execute APM style suspend command
37         exec apm -z
38 else
39         echo "Error: no ACPI or APM suspend support found."
40 fi
41
42 exit 1