Regarding my observation that the processes keep running after I &quot;sudo service nut stop&quot;, I found this isn&#39;t exactly the case. I think what happens is that if I forget the &quot;sudo&quot; in front of the command, it comes up with the &quot;Stopping Nut Tools... Done&quot; 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 &quot;$1&quot; in</div><div>                hibernate|suspend)</div><div>                        echo &quot;Initiating UPS Powerdown Sequence&quot;</div>
<div>                        /sbin/upsdrvctl shutdown</div><div>                        echo &quot;Stopping nut service&quot;</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&#39;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&#39;m going back to my single line SHUTDWNCMD which actually worked.</div>
<div><br></div><div>David</div><div><br></div>