Basic hardware configuration

Configuring APM using pwrsh

As an alternative to configuring the pwrd daemon, you can use the pwrsh(ADM) command to configure, control, or query the power management facilities of your system after it has booted. Typically, you would run pwrsh regularly as a crontab(C) entry for root to check the charge status of the batteries and take appropriate action if necessary. To prevent interaction with pwrd, change the command (cmd) associated with the appropriate event's action to ``exit 0''. See ``Checking battery status regularly'' for an example of how to do this.

WARNING: BIOS-APM firmware from different manufacturers varies considerably in operation and efficacy. What may be a safe or useful sequence of commands on one machine may be ineffectual or worse on another.

pwrsh can read commands from the command line (using the -c option) from a specified file, from the standard input, or interactively. If you run pwrsh interactively, use the ? or help command for information about other commands. Enter quit or <Ctrl>D to leave pwrsh. You can use the status command to obtain the boot-time, previous, or current power status of the machine's AC supply and batteries:

/etc/pwr/bin/pwrsh -c "status -b -AB # print boot-time power status"
/etc/pwr/bin/pwrsh -c "status -n -AB # print previous power status"
/etc/pwr/bin/pwrsh -c "status -AB # print current power status"

You can also specify a power test condition to the status command in the style of hasapm(ADM) -- see also the description for the apm.boot and apm.warn in ``Advanced Power Management bootstrings''. pwrsh exits with a value determined by the last command executed. When a test is used with the status command, this is the result of the test:

[ /etc/pwr/bin/pwrsh -c "status -s \
! & (!charge.low | !charge.critical | \
(!charge.unknown & % <= 25))" ] \
&& echo "No AC power and battery charge is low!"

You can use the state command to turn the system or peripheral devices on (Ready) or Off, make them Idle but automatically ready for use, or Freeze them to conserve data.

NOTE: Some BIOS-APM firmware can only Freeze the entire system or turn Off individual peripherals.

For example, the following command idles the entire system if battery power is low and the AC supply is not being used:

[ /etc/pwr/bin/pwrsh -c "status -s \
! & ( charge.low | charge.critical )" ] \
&& /etc/pwr/bin/pwrsh -c "state -i all"

The following command freezes the video screen and keyboard and idles the hard and floppy disks:

/etc/pwr/bin/pwrsh -c "state -f display \
state -i storage"

Checking battery status regularly

The following crontab entry for root calls the executable file /usr/local/bin/check_batts every 15 minutes:

   15 * * * * /usr/local/bin/check_batts 2>&1 | mail root
The check_batts script checks the charge status of the batteries. If the batteries are low, it warns all users and shuts down the system:
   [ /etc/pwr/bin/pwrsh -c "status -s ! &
      ( charge.low | charge.critical )" ]
   /etc/shutdown -y -i0 -g00:05 -f "No AC power and battery charge is low!
   System will shut down in 5 minutes - log off now!"
You should also disable pwrd's handling of low battery charge. To do this, edit the entry for the ``apm/batteries-are-low'' (classname/event) entry in /etc/pwr/sys/actions. Change the entry to read:
   system/lowbattery-1:apm/batteries-are-low::exit 0
then shut down and reboot the system.

WARNING: If you turn off the power to the entire system or to the hard disk(s), you risk losing valuable data and damaging the integrity of filesystems.

Previous topic: Configuring Power Management

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003