title: How to specify commands to be run before shutdown with NUT in case of power & network failure?
body: <p>I have a NAS with a usb plugged UPS on it.
  I have installed nut client (only the client) on my raspberry to monitor the UPS. 
  I must plug the UPS to the NAS because it's the only device which recognizes my UPS (chinese generic, unfortunately no choice in my country). 
  No way to make it directly work plugged to the raspberry.
  As I've installed only nut client into my raspberry, /etc/nut was empty. I've created 3 files:</p>
  
  <p>nut.conf</p>
  
  <pre><code>MODE=netclient
  </code></pre>
  
  <p>upsmon.conf</p>
  
  <pre><code>MONITOR login@nas_ip 1 admin password slave
  SHUTDOWNCMD "/sbin/shutdown -h now"
  NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
  NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
  NOTIFYCMD "/etc/nut/notifycmd"
  </code></pre>
  
  <p>the notifycmd script:</p>
  
  <pre><code>    #!/bin/bash
  #
  # NUT NOTIFYCMD script
  
  PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
  
  trap "exit 0" SIGTERM
  
  if [ "$NOTIFYTYPE" = "ONLINE" ]
  then
          echo $0: power restored | wall
  # curl command to send me a sms
          # Cause all instances of this script to exit.
          killall -s SIGTERM `basename $0`
  fi
  
  if [ "$NOTIFYTYPE" = "ONBATT" ]
  then
          echo $0: 40 minutes till system powers down... | wall
  #curl command to send me a sms
          # Loop with one second interval to allow SIGTERM reception.
          let "n = 2400"
          while [ $n -ne 0 ]
          do
                  sleep 1
                  let "n--"
          done
          echo $0: commencing shutdown | wall
          sleep 10
          upsmon -c fsd
  fi
  </code></pre>
  
  <p>My UPS is powerful enough to wait 40 minutes before shuting down the nas and the raspberry remotely.
  I receive a sms when power loss and power restored.</p>
  
  <p>But there is a special case: if the raspberry lost connection with the ups when it is on battery, the raspberry shut down almost immediately... I think this is a protection behavior, but i'd like to insert a curl command which sends a sms before shutdown, like "power loss and connexion failure with ups"
  (i know the command itself, this is not the problem)
  I know I must add something like "DEADTIME" or "NOTIFYFLAG NOCOMM" or "COMMBAD" in upsmon.conf, but not sure what to choose...
  And what do i have to add in my "notifycmd" file ?</p>
  
  <p>Thanks</p>