Files
Unraid-SlackPack/source/nut/usr/local/emhttp/plugins/nut/scripts/notifycmd_timeout
2017-04-28 20:20:51 -06:00

31 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
#
# NUT NOTIFYCMD script macester macecapri@gmail.com
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
TIMEOUT=240
trap "exit 0" SIGTERM
if [ "$NOTIFYTYPE" = "ONLINE" ]
then
echo $0: power restored | wall
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is no longer on battery" -i "normal"
# Cause all instances of this script to exit.
killall -s SIGTERM `basename $0`
fi
if [ "$NOTIFYTYPE" = "ONBATT" ]
then
echo $0: $TIMEOUT seconds till system powers down... | wall
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is on battery" -i "alert"
# Loop with one second interval to allow SIGTERM reception.
let "n = $TIMEOUT"
while [ $n -ne 0 ]
do
sleep 1
let "n--"
done
echo $0: commencing shutdown | wall
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "UPS Notification" -s "UPS is shutting down unRAID" -i "alert"
upsmon -c fsd
fi