As halt.sh no longer exists ...
Created attachment 188920 [details] nut killpower init script
That should be added to the shutdown runlevel.
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.
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?
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.
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)
Kjell, are you advocating the lack of an infinite loop because of a "normal runtime" ?
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.
Marking as a blocker to the openrc stablereq bug because sys-power/nut is marked stable.
Robin, can we get an update on this since it is blocking openrc stabilization? Thanks, William
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.
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.
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.