Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 266804 - sys-power/nut requires init script for OpenRC to kill power
Summary: sys-power/nut requires init script for OpenRC to kill power
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Robin Johnson
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 295613
  Show dependency tree
 
Reported: 2009-04-19 20:44 UTC by Roy Marples
Modified: 2010-01-09 20:18 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
nut killpower init script (nut,464 bytes, text/plain)
2009-04-19 20:44 UTC, Roy Marples
Details
New ups-off script with infinit loop. (ups-off,521 bytes, text/plain)
2010-01-09 11:21 UTC, Kjell Claesson
Details
supports both nut and apcupsd (with infinite loop) (powerfail,686 bytes, text/plain)
2010-01-09 17:59 UTC, Ștefan Talpalaru
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roy Marples 2009-04-19 20:44:05 UTC
As halt.sh no longer exists ...
Comment 1 Roy Marples 2009-04-19 20:44:54 UTC
Created attachment 188920 [details]
nut killpower init script
Comment 2 Roy Marples 2009-04-19 20:48:02 UTC
That should be added to the shutdown runlevel.
Comment 3 Ștefan Talpalaru 2009-04-19 22:09:46 UTC
An infinite loop at the end of start() is actually required because the delay until the UPS does the actual shutdown after receiving the signal is configurable (at least in my APC Back-UPS ES 550).

The magic '120' value might not cover all cases and if the script exits before the power is cut it will trigger a normal shutdown compromising the automatic restart mechanism.
Comment 4 Roy Marples 2009-04-19 22:32:12 UTC
This is based on what a user sent me - I don't actually use UPS myself.

Also, the old halt.sh script called "halt -id".
Does this need to as well?
Comment 5 Ștefan Talpalaru 2009-04-19 22:44:25 UTC
According to the man page "halt -id" shuts down the network interfaces. I don't know why this is done in the old script or if it's relevant after net.xxxx is stopped.
Comment 6 Kjell Claesson 2009-04-20 17:13:42 UTC
Hi,

As I was the user that sent the script I can answer for the function.
This script is run at the end of the shutdown. So everything is halted,
like network interface and so on. So the only thing it does is sending the
power off to the ups. And in that state you don't have to have a long shutdown
delay.

A normal runtime after the ups have reached OnBatt LowBatt is about 2 min, But this is configurable in some ups'es. You can tell it to send OB LB early to have more runtime left. This is good if you need to wait for raid systems and
so on to go down. But this would not kill the power of the ups.

So after it send shutdown to the computer (not to the ups) it start shutdown and use the time (runtime on battery low). When it hit this script it
is not so much time left on the runtime, and if it fail to shut down the ups
it sends a warning after 2 min. (and this is an infinit loop. You have to manualy shut of the ups.) Many ups'es have given up at this time.

I use powerware ups'es, and use a shutdown_delay of 10 sec. They normaly have a
runtime of about 120 sec on LowBattery, so i have about 120 sec to reach this
script. I have not timed it but I think it take about 12 sec to shutdown my
computer after it hit OB LB so when I hit the script I send poweroff with a 
delay of 10 sec to the ups, so i have about 100sec left.

The runtime on battery is not configurable in the bcmxcp driver for powerware
as I at the moment don't have time to fix the code for that.

Read the shutdown.txt in the doc of NUT it explain the functions.

Regards
Kjell (bcmxcp author and member of the NUT team)
Comment 7 Ștefan Talpalaru 2009-04-20 22:55:13 UTC
Kjell, are you advocating the lack of an infinite loop because of a "normal runtime" ?
Comment 8 Kjell Claesson 2009-04-21 15:58:54 UTC
Stefan you are right about the infinite loop.

Quote:
The magic '120' value might not cover all cases and if the script exits before
the power is cut it will trigger a normal shutdown compromising the automatic
restart mechanism.
Unquote

So after the warning there must be a loop that stop it from completing the
normal shutdown.
Comment 9 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-12-21 23:11:55 UTC
Marking as a blocker to the openrc stablereq bug because sys-power/nut is marked stable.
Comment 10 William Hubbs gentoo-dev 2010-01-09 01:51:11 UTC
Robin,

can we get an update on this since it is blocking openrc stabilization?

Thanks,

William

Comment 11 Kjell Claesson 2010-01-09 11:21:00 UTC
Created attachment 215789 [details]
New ups-off script with infinit loop.

Attach a new ups-off script. This have a infinit loop that echo
the warning every 10 seconds.

Best if you can test it. I have no machine that I can(want)power off at
the moment.
Comment 12 Ștefan Talpalaru 2010-01-09 17:59:16 UTC
Created attachment 215835 [details]
supports both nut and apcupsd (with infinite loop)

The attached script has been in use with nut for the last 8 months.
Comment 13 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-01-09 20:18:16 UTC
Committed in nut-2.4.1-r2, with more changes to the init script so that it doesn't timeout, or get run on various vm setups, and works with pure SH.