Nice script, tjc. Thanks!
apcupsd worked perfectly. Shutdown my box nicely during a simulated power failure.
However, I'd like to also set the system to wakeup to record and to run mythfilldatabase (and maybe to wake on lan.. not sure yet about this one).
The question is then: if the box is powered off by apcupsd and then the power is back and it is then time to record... will the system simply wake up?
or do i have to change /etc/init.d/halt as directed on apcupsd's manual, so that right before the system shuts down (during a power failure), apcupsd is reran with the --killpower option??
See
http://www.apcupsd.org/manual/After_Ins ... 0000000000
http://www.apcupsd.org/manual/Shutown_S ... 003c1_003e
How do these two things play together?? For instance:
a) If apcupsd is set to reboot the system after power comes back AND I set the box to wake up for recording, then will there be a problem if there's no power yet but it is time to record??? Or do the two procedures work differently and they don't contradict each other?
b) Do I or do I not need to make apcupsd reboot the pc after power comes back? And if I do need to make it reboot, then which way? The BIOS way, by editing halt, or by changing "poweroff" to "halt" in /etc/default/halt, or something else???
Thanks for shedding any light on this issue!!!
EDIT: If I'm using
http://www.knoppmythwiki.org/index.php? ... ythWelcome to make the box wake up to record, then it SEEMS the halt command is what shuts the system down. If I'm right and it IS the same halt command apcupsd uses to power the machine off, then I shouldn't really do anything! (or is it halt -p for nvram verses halt for upcusbd???) Am I correct that if I just install apcupsd with tjc's script and then follow that wiki and make the system wake up to record (maybe changing halt -p to just halt in nvram's settings in myth-setup??) then I'll have the following behavior?
a) with power not interrupted, the system shuts down when idle
b) with power being interrupted, the system also shuts down
c) while the machine is off (whether due to idling or power outage), if the power comes back nothing happens.. power goes off again.. still nothing happens.. and so on!
d) while the system is down (whether due to idling or power outage), if it is time to record the system tries to wake up
d1) if the battery has shut itself off, the system will not be able to reboot
d2) if the power is on, the system will wake up
that would be ideal! but is it how it really would work???
the only problem is if power goes off, the battery shuts the system down, and before the battery turns off a recording says the system should wake up! then during the boot process, the battery will power the system off!!!
i guess this can be avoided by setting a small grace period, decreasing the chance of this situation occurring. can anyone see a problem with a small grace period?
btw, the KM default is 20 seconds while apcupsd's default is 180 seconds. is this behavior the reason for having the smaller default in KM??!!
and what happens if while the system is powering up, the power goes off!! i guess the battery waits till the system is up and running, then starts doing its magic? [i'd think that's how it SHOULD work!]
Thanks for any answers to any of these questions!!!!