hassio-addons/upsmon/run.sh

32 lines
695 B
Bash
Raw Normal View History

2018-11-08 20:56:10 +00:00
#!/bin/bash
set -e
CONFIG_PATH=/data/options.json
2018-11-08 21:05:44 +00:00
UPSNAME=$(jq --raw-output ".ups.upsname" $CONFIG_PATH)
HOST=$(jq --raw-output ".ups.host" $CONFIG_PATH)
USER=$(jq --raw-output ".credentials.user" $CONFIG_PATH)
PASS=$(jq --raw-output ".credentials.pass" $CONFIG_PATH)
2018-11-08 20:56:10 +00:00
DELAY=$(jq --raw-output ".delay" $CONFIG_PATH)
echo "
MONITOR ${UPSNAME}@${HOST} 1 ${USER} ${PASS} slave
MINSUPPLIES 1
SHUTDOWNCMD \"/sbin/shutdown -h +0\"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY ${DELAY}
" > /etc/nut/upsmon.conf
echo "MODE=netclient" > /etc/nut/nut.conf
# change perms on config files
chmod 660 /etc/nut/*
upsmon -D