<br><br><div class="gmail_quote">On Fri, 17 Dec 2010 17:41:39 +0100, <span dir="ltr">Arjen de Korte &lt;<a href="mailto:nut%2Busers@de-korte.org">nut+users@de-korte.org</a>&gt;</span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>Citeren David Varley &lt;<a href="mailto:davidavarley@gmail.com" target="_blank">davidavarley@gmail.com</a>&gt;:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
As far as setting the shutdown command in a script run when hibernating, I<br>
did this. I created a script, 48nut, in /etc/pm/sleep.d, as follows:<br>
<br>
#!/bin/sh<br>
# If we are hibernating due to power-fail, initiate a delayed UPS shutdown<br>
and then stop the nut services<br>
# If we are thawing after this event, start the nut service<br>
# DAV 17DEC10<br>
<br>
   if (test -f /etc/killpower)<br>
   then<br>
        case &quot;$1&quot; in<br>
                hibernate|suspend)<br>
                        echo &quot;Initiating UPS Powerdown Sequence&quot;<br>
                        /sbin/upsdrvctl shutdown<br>
                        echo &quot;Stopping nut service&quot;<br>
                        service nut stop<br>
</blockquote>
<br>
This won&#39;t work. In order to send a poweroff command to the UPS, the drivers must be restarted from scratch. Therefor you must run &#39;service nut stop&#39; before doing that, otherwise the backgrounded drivers will not have exited.<br>

<br>
It also is a good idea to put a &#39;sleep 2&#39; between the two commands, to give the drivers some time to respond to the KILL signal they receive:<br>
<br>
    echo &quot;Stopping nut service&quot;<br>
    service nut stop<br>
    sleep 2<br>
    echo &quot;Initiating UPS Powerdown Sequence&quot;<br>
    /sbin/upsdrvctl shutdown<br>
<br>
Best regards, Arjen<br></blockquote><div> </div></div>Arjen, now I&#39;m a bit confused. In your script you are saying to shut down nut before issuing the upsdrvctl command to tell the UPS to start a delayed shutdown. But as shutting down nut causes the usbhid-ups driver to exit, I thought that would prevent the command being sent to the UPS? I know that if I just have the upsdrvctl shutdown command without telling the nut service to exit, the UPS shuts down after the 60 second delay. I can understand adding the delay after giving the shutdown command and before stopping the services, but not the other way around. What am I missing here?<div>
<br></div><div>Thanks, David</div><div> </div>