1 | #!/sbin/runscript |
---|
2 | # Copyright 1999-2009 Gentoo Foundation |
---|
3 | # Distributed under the terms of the GNU General Public License v2 |
---|
4 | # $Header: $ |
---|
5 | |
---|
6 | depend() { |
---|
7 | need mount-ro |
---|
8 | } |
---|
9 | |
---|
10 | start() { |
---|
11 | local UPS_CTL UPS_POWERDOWN |
---|
12 | |
---|
13 | if [[ -f /etc/killpower ]] ; then |
---|
14 | UPS_CTL=/usr/sbin/upsdrvctl |
---|
15 | UPS_POWERDOWN="${UPS_CTL} shutdown" |
---|
16 | elif [[ -f /etc/apcupsd/powerfail ]] ; then |
---|
17 | UPS_CTL=/sbin/apcupsd |
---|
18 | UPS_POWERDOWN="${UPS_CTL} --killpower" |
---|
19 | else |
---|
20 | return 0 |
---|
21 | fi |
---|
22 | |
---|
23 | if [[ $(runlevel) == *' 0' && -f ${UPS_CTL} ]] ; then |
---|
24 | ebegin 'Signaling UPS to kill power' |
---|
25 | ${UPS_POWERDOWN} |
---|
26 | eend $? |
---|
27 | ebegin 'Halt system and wait for the UPS to kill our power' |
---|
28 | /sbin/halt -id |
---|
29 | while [ 1 ]; do sleep 60; done |
---|
30 | fi |
---|
31 | } |
---|
32 | |
---|