#!/sbin/runscript # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ depend() { need mount-ro } start() { local UPS_CTL UPS_POWERDOWN if [[ -f /etc/killpower ]] ; then UPS_CTL=/usr/sbin/upsdrvctl UPS_POWERDOWN="${UPS_CTL} shutdown" elif [[ -f /etc/apcupsd/powerfail ]] ; then UPS_CTL=/sbin/apcupsd UPS_POWERDOWN="${UPS_CTL} --killpower" else return 0 fi if [[ $(runlevel) == *' 0' && -f ${UPS_CTL} ]] ; then ebegin 'Signaling UPS to kill power' ${UPS_POWERDOWN} eend $? ebegin 'Halt system and wait for the UPS to kill our power' /sbin/halt -id while [ 1 ]; do sleep 60; done fi }