1
1
I’m looking for help in shutting down my iMac on detecting a power failure while running from a UPS.
My setup is an APC SMT750i UPS, powering two Synology NASs, and iMac plus the network kit (router, switch etc.). This is all fine. Synology runs a variant of Linux and NUT. I have installed NUT (v 2.6.5) on the iMac (High Sierra 10.13.6) using MacPorts. One NAS is connected directly to the UPS via USB and acts as the ‘master’ in the NUT network, the other NAS and the iMac are ‘slaves’.
On power failure, the master detects the state of the UPS and broadcasts it to the slaves, which both receive it OK. The NASs both go into ‘safe mode’ correctly as they are configured to do. The iMac receives the state change OK and repeatedly alerts the logged in user, but does NOT in fact shut down, as I want and believe I have configured it to do.
I have followed all the advice I can find online, especially at:
How to Automatically Launch NUT Client at Boot on MacOS
https://diktiosolutions.eu/en/synology/synology-ups-nut-en/
What am I doing wrong?
Mac NUT config files:
etc/upsmon.conf
RUN_AS_USER root
MONITOR ups@xxx.xxx.xxx.xxx 1 monuser ****** slave
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -u -h +1"
NOTIFYCMD /opt/local/sbin/upssched
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
NOTIFYFLAG ONLINE EXEC+SYSLOG+WALL
NOTIFYFLAG ONBATT EXEC+SYSLOG+WALL
NOTIFYFLAG LOWBATT EXEC+SYSLOG+WALL
NOTIFYFLAG FSD EXEC+SYSLOG+WALL
NOTIFYFLAG COMMOK EXEC+SYSLOG
NOTIFYFLAG COMMBAD EXEC+SYSLOG
NOTIFYFLAG SHUTDOWN EXEC+SYSLOG+WALL
NOTIFYFLAG REPLBATT EXEC+SYSLOG+WALL
NOTIFYFLAG NOCOMM EXEC+SYSLOG+WALL
NOTIFYFLAG NOPARENT EXEC+SYSLOG+WALL
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
etc/upssched.conf
CMDSCRIPT /opt/local/bin/upssched-cmd
PIPEFN /opt/local/var/db/ups/upssched/upssched.pipe
LOCKFN /opt/local/var/db/ups/upssched/upssched.lock
AT ONBATT ups@xxx.xxx.xxx.xxx EXECUTE on-battery
AT ONLINE ups@xxx.xxx.xxx.xxx EXECUTE ups-back-on-line
AT COMMBAD ups@xxx.xxx.xxx.xxx START-TIMER upsgone 75
AT COMMOK ups@xxx.xxx.xxx.xxx CANCEL-TIMER upsgone
bin/upssched-cmd
#! /bin/sh
case $1 in
upsgone)
logger -t upssched-cmd "Lost communication with UPS"
/usr/bin/osascript -e 'tell app (path to frontmost application as text) to display dialog "Lost contact with UPS server" buttons {"OK"} default button 1 with icon note'
;;
on-battery)
logger -t upssched-cmd "UPS is running on battery"
/usr/bin/osascript -e 'tell app "System Events" to display dialog "Power failure. Save your work" buttons {"OK"} default button 1'
;;
ups-back-on-line)
logger -t upssched-cmd "UPS is running on utility power"
/usr/bin/osascript -e 'tell app (path to frontmost application as text) to display dialog "Power restored to UPS" giving up after 600 buttons {"OK"} default button 1 with icon note'
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
/usr/bin/osascript -e "tell app (path to frontmost application as text) to display dialog \"upssched-cmd: unsupported command $1\" buttons {\"OK\"} default button 1 with icon caution"
;;
esac