hassio-addons/upsmon/run.sh
2018-11-22 13:10:16 +01:00

31 lines
667 B
Bash

#!/bin/bash
set -e
CONFIG_PATH=/data/options.json
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)
DELAY=$(jq --raw-output ".delay" $CONFIG_PATH)
echo "
MONITOR ${UPSNAME}@${HOST} 1 ${USER} ${PASS} slave
MINSUPPLIES 1
SHUTDOWNCMD \"/shutdown.sh\"
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