Regarding my observation that the processes keep running after I "sudo service nut stop", I found this isn't exactly the case. I think what happens is that if I forget the "sudo" in front of the command, it comes up with the "Stopping Nut Tools... Done" line, as if it worked, however it actually failed and the processes are still running. If I then start the services again, it actually starts another instance, that is there are two copies of the usb driver running. (And leaving complaining messages in the log!)<div>
If I then stop the services (correctly, with the sudo) one still remains, and it can only be stopped with an explicit kill command. This is what I was seeing.</div><div><br></div><div><br></div><div>As far as setting the shutdown command in a script run when hibernating, I did this. I created a script, 48nut, in /etc/pm/sleep.d, as follows:</div>
<div><br></div><div><div>#!/bin/sh</div><div># If we are hibernating due to power-fail, initiate a delayed UPS shutdown and then stop the nut services</div><div># If we are thawing after this event, start the nut service</div>
<div># DAV 17DEC10</div><div><br></div><div> if (test -f /etc/killpower)</div><div> then</div><div> case "$1" in</div><div> hibernate|suspend)</div><div> echo "Initiating UPS Powerdown Sequence"</div>
<div> /sbin/upsdrvctl shutdown</div><div> echo "Stopping nut service"</div><div> service nut stop</div><div> ;;</div><div>
thaw|resume)</div><div> service nut start</div><div> ;;</div><div> *) exit $NA</div><div> ;;</div><div> esac</div>
<div> fi</div></div><div><br></div><div>Unfortunately it didn't work, perhaps the service is stopped before the shutdown has a chance to take effect. In /var/log/pm-suspend.log. On hibernate I see:</div><div><br></div>
<div><div>/etc/pm/sleep.d/48nut hibernate hibernate:Initiating UPS Powerdown Sequence</div><div><b>Startup timer elapsed, continuing...</b></div><div>Network UPS Tools - UPS driver controller 2.4.3</div><div>Stopping nut service</div>
<div> * Stopping Network UPS Tools</div><div> ...done.</div><div>success.</div><div>/usr/lib/pm-utils/sleep.d/49bluetooth hibernate hibernate:not applicable.</div></div><div><br></div><div>Then on thaw I see:</div><div>
<br></div><div><div>/usr/lib/pm-utils/sleep.d/49bluetooth thaw hibernate:not applicable.</div><div>/etc/pm/sleep.d/48nut thaw hibernate: * Starting Network UPS Tools</div></div><div><br></div><div>however the shutdown never occurs, and after the thaw the nut services are not running!</div>
<div>If I have the shutdown command in the script, but not the command to stop the nut services, then the UPS does shut down.</div><div><br></div><div>So, for now I'm going back to my single line SHUTDWNCMD which actually worked.</div>
<div><br></div><div>David</div><div><br></div>