Configuring UPS
If you have an uninterrupted power supply device from APC corporation, you can automate your system startup and shutdown when running on batteries using the open source tool called apcupsd.
$ sudo emerge -av apcupsd
Have a look at the possible USE flags for the package and put an entry in your /etc/portage/package.use if desired. Afterward, emerge the package.
Once emerged, edit the configuration file to suit your needs.
$ sudo nano -w /etc/apcupsd/apcupsd.conf
Edit the hosts.conf file to enable cgi web monitoring.
$ sudo nano -w /etc/apcupsd/hosts.conf
Add your email address and particulars to the files changeme,onbattery and offbattery if you want notifications when the power goes out. Note that notifications may not work unless you change the APCUPSD_MAIL directive from /bin/mail to /usr/bin/sendmail.
Next, set apcupsd to start with the system.
$ sudo rc-update add apcupsd default
Start the service.
$ sudo /etc/init.d/apcupsd start
To view your UPS's statistics once the service has started,
$ sudo apcaccess status