The idea is to have a single tool which can handle a variety of situations without need to hack the source code. This version of powerd can be configured either on the command line or by means of a configuration file. This version of powerd is designed to work with init release 2.4 or later under the Linux environment.
The program performs two tasks: it brings down the system to single-user mode when a powerfail is detected, and it brings back the system to multi-user mode when the power is back. Proper setup of the system startup files is required, as explained in both the UPS-HOWTO and the README file of powerd itself.
powerd
This simplest invocation causes powerd to read the default
configuration file, /etc/powerd.conf.
powerd /dev/ttyS0
powerd /dev/cua0
powerd /var/run/upsctl
powerd /etc/powerd.conf.new
When infoked with a single argument, the program behaves differently according the the file type: if it is a regular file it is used in place of the default configuration file; if it is a fifo it is used as the monitoring information, and powerd waits for "OK" or "FAIL"; if it is a serial device it is used to monitor the DCD line, like powerd version 1 used to do.
powerd /dev/cua0 -port 1043
If a tcp port is specified last in the command
line, powerd uses it to report information to
clients. Powerd becomes a network server.
powerd -host jupiter 1043
The daemon will connect as a client to the specified
TCP port of a remote server. Powerd's running
on different computers, using "-port"/"-host" can
happily be used to handle a single UPS feeding
power to more than one computer.
powerd serialline=/dev/cua1 monitor=DCD failwhen=high If needed, the whole configuration file can be fed on the command line. Possible commands are listed below.
Note that the separator is one or more white spaces, while on the command line the separator is the `=' sign.
option is the first word on the line, and value is the following word. if value nedds to be more than one word, enclose it within double quotes. Boolean entities can do without a value field.
The followin keywords may appear in the configuration file. The description here is quite skeletal, and you should refer to the sample powerd.conf distributed with the powerd source code.
disabled
Boolean, on by default. A disabled daemon only
generates messages, without shutting down the system.
delay seconds
Wait before taking action, and re-sample the input
later. To ignore glitches. Default is 0 for network
clients and 10 otherwise.
debug Boolean. If on it disables fork()ing and prints many messages on stderr.
logfile filename
Even if debug is on, fork, and redirect stderr to
the specified file.
remoteserver hostname
Use the remote host as source for power information.
serverport portnumber
Number of the UDP port to use, as server or client.
If the port is specified and "remoteserver" is not,
this host is the server.
timeout seconds
Time to wait for a server reply before retrial.
trials number
How many times to try the connection. If that
fails, the daemon exits.
serialline pathname
Use the serial device as source for power information.
monitor signal_name
Tell which signal (wire) conveys info. Defaults to
`DCD'.
failwhen condition
Either ``high'', ``low'' or a string, according to
what is being monitored,
asserthigh signal_name
Toggle an outgoing serial signal (wire), and delay
one second before proceeding.
assertlow signal_name
The same.
pollingstep seconds
Time to wait between samples when information comes
from a non-selectable agent (like the serial port),
or via udp (network).
readfifo pathname
Use a fifo as source for power information. Mainly
for hand-testing.
spawnmonitor commandline
Invoke an external program, using its stdout as
source for power information.