1
I'm trying to run NUT (Network UPS Tools) on my Mac (MacOS 10.9.5) so that my Mac mini server will shutdown cleanly in the event of a power outage and the UPS battery runs out. I've been following these instructions:
I've got the NUT server running on my Synology NAS and the NUT client installed on my Mac mini (via Fink) and can manually launch it by doing:
sudo upsmon
I pulled the power on the UPS and saw power events written to the Terminal and to the Console. I haven't let it drain all the way down yet, but it appears to be working so far.
My issue is that I've been unable to get it automatically launch with OS X. I've tried running a script that was included with the instructions:
#!/bin/sh
##
# UPS Monitor script
# Using Network UPS Tools executables
##
. /etc/rc.common
FINK_BIN="/sw/sbin"
StartService ()
{
ConsoleMessage "Starting NUT (UPS Service)"
if [ -n "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
ConsoleMessage -f "NUT (UPS Service)"
echo "Failed to start NUT (UPS Service): It is already running."
exit 0
fi
${FINK_BIN}/upsmon &
if [ -n "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
ConsoleMessage -s "NUT (UPS Service)"
echo "NUT (UPS Service) successfully started."
exit 0
else
ConsoleMessage -f "NUT (UPS Service)"
echo "Failed to start NUT (UPS Service): Either the application has been deleted or it has no execution right."
exit 0
fi
}
StopService ()
{
ConsoleMessage "Stopping NUT (UPS Service)"
if [ -z "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
ConsoleMessage -s "NUT (UPS Service)"
echo "Failed to stop NUT (UPS Service): It is not running."
exit 0
fi
${FINK_BIN}/upsmon -c stop
if [ -n "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
ConsoleMessage -s "NUT (UPS Service)"
echo "Failed to stop NUT (UPS Service) out of unknown reason."
exit 0
else
ConsoleMessage -s "NUT (UPS Service)"
echo "NUT (UPS Service) successfully stopped."
exit 0
fi
}
StopServiceForcefully()
{
ConsoleMessage "Stopping NUT (UPS Service)"
if [ -z "`ps acx | grep -i "upsmon" | awk {'print $1'}`" ]; then
echo "Failed to stop NUT (UPS Service): It is not running."
else
kill -kill `ps acxw | grep -i "upsmon" | awk {'print $1'}`
if [ -n "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
echo "Failed to stop NUT (UPS Service) out of unknown reason."
else
echo "NUT (UPS Service) successfully stopped."
fi
fi
}
RestartService()
{
ConsoleMessage "Trying to restart NUT (UPS Service)."
StopService
StartService
exit 0
}
RunService "$1"
However, I get this error in Terminal:
line 75: $1: unbound variable
Can this script be fixed? Is it possible to just create a new script that will just launch upsmon and keep it simple. I can't figure it out; I've tried a few things to do just that but couldn't get it to work.
Anyone know of a way to get this to launch automatically? – interconnect – 2017-07-13T11:29:38.403