Last active
April 22, 2024 06:30
-
-
Save twaddington/4b06a55aabc5ef431919b976176a551b to your computer and use it in GitHub Desktop.
Network UPS Tools (NUT) on Debian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MODE=standalone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Allow nut group to execute shutdown command | |
%nut ALL=NOPASSWD: /sbin/shutdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set maxretry to 3 by default, this should mitigate race with slow devices: | |
maxretry = 3 | |
[eaton] | |
driver = usbhid-ups | |
port = auto | |
vendorid = 0463 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[upsmon] | |
password = 1234 | |
upsmon master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MONITOR eaton@localhost 1 upsmon 1234 master | |
NOTIFYCMD /sbin/upssched | |
NOTIFYFLAG ONLINE SYSLOG+EXEC | |
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC | |
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC | |
MINSUPPLIES 1 | |
SHUTDOWNCMD "/sbin/shutdown -h +0" | |
POLLFREQ 5 | |
POLLFREQALERT 5 | |
HOSTSYNC 15 | |
DEADTIME 15 | |
POWERDOWNFLAG /etc/killpower | |
RBWARNTIME 43200 | |
NOCOMMWARNTIME 300 | |
FINALDELAY 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# | |
# This script should be called by upssched via the CMDSCRIPT directive. | |
# | |
# Here is a quick example to show how to handle a bunch of possible | |
# timer names with the help of the case structure. | |
# | |
# This script may be replaced with another program without harm. | |
# | |
# The first argument passed to your CMDSCRIPT is the name of the timer | |
# from your AT lines. | |
case $1 in | |
onbattwarn) | |
sudo /sbin/shutdown -h +5 | |
logger -t upssched-cmd "The UPS is on battery power" | |
;; | |
ups-back-on-power) | |
sudo /sbin/shutdown -c | |
logger -t upssched-cmd "The UPS is back on wall power" | |
;; | |
*) | |
logger -t upssched-cmd "Unrecognized command: $1" | |
;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CMDSCRIPT /usr/local/bin/upssched-cmd | |
PIPEFN /var/run/nut/upssched.pipe | |
LOCKFN /var/run/nut/upssched.lock | |
AT ONBATT * EXECUTE onbattwarn | |
AT ONLINE * EXECUTE ups-back-on-power |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also https://www.kepstin.ca/blog/networkupstoolsnutandsystemd/