hassio-addons/upsmon/run.sh

31 lines
667 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
2018-11-22 12:10:16 +00:00
SHUTDOWNCMD \"/shutdown.sh\"
2018-11-08 20:56:10 +00:00
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
" > /etc/nut/upsmon.conf
echo "MODE=netclient" > /etc/nut/nut.conf
# change perms on config files
chmod 660 /etc/nut/*
upsmon -D