<div dir="ltr"><div>Dear all,</div><div><br></div><div>I would like to gracefully shut down my router (Unifi Dream Router (UDR)) after my secondary has shut off, and before my primary shuts off (or in any case, before the UPS powers down). Unfortunately, the router doesn't seem to support NUT, but I've written a bash script, with which I can shut it down as user <i>nut</i>, running command <i>sudo -H -u nut bash -c 'bash /var/lib/nut/NUT-scripts/shutdownrouter.sh'</i>). (I assume that if any script is to be run, it would be run as user <i>nut</i>.)</div><div><br></div><div>But now I'm trying to figure out how to call it, and I'm not sure...</div><div><ul><li>I assume in <i>upsmon.conf</i> there should be a line <i>NOTIFYFLAG FSD      SYSLOG+WALL+EXEC</i>)<br>But then I wondered whether <i>FSD</i> was maybe too late a flag?</li><li>Then I assume <i>upssched.conf</i> plays a role. This is the current setup:<br><br>CMDSCRIPT /etc/nut/upssched-cmd.sh<br>PIPEFN /etc/nut/upssched.pipe<br>LOCKFN /etc/nut/upssched.lock<br>AT ONBATT * START-TIMER shutdown_timer 1200<br>AT ONLINE * CANCEL-TIMER shutdown_timer<br>AT LOWBATT * EXECUTE immediate_shutdown<br>AT COMMBAD * START-TIMER commbad_timer 1200<br>AT COMMOK * CANCEL-TIMER commbad_timer<br>AT NOCOMM * EXECUTE commbad_shutdown<br>AT SHUTDOWN * EXECUTE powerdown<br><br></li><li>Then I assume <i>upssched-cmd.sh</i> plays a role. This is the current setup:<br>#!/bin/sh<br><br>case $1 in<br>    shutdown_timer)<br>        logger -t upssched-cmd "UPS running on battery for too long, initiating shutdown"<br>        /usr/sbin/upsmon -c fsd<br>        ;;<br><br>    immediate_shutdown)<br>        logger -t upssched-cmd "UPS on battery critical, forced shutdown"<br>        /usr/sbin/upsmon -c fsd<br>        ;;<br><br>    commbad_timer)<br>        logger -t upssched-cmd "UPS communication failure persists, initiating shutdown"<br>        /usr/sbin/upsmon -c fsd<br>        ;;<br><br>    commbad_shutdown)<br>        logger -t upssched-cmd "UPS communication failed, initiating shutdown"<br>        /usr/sbin/upsmon -c fsd<br>        ;;<br><br>    powerdown)<br>        logger -t upssched-cmd "Executing powerdown command"<br>        ;;<br><br>    *)<br>        logger -t upssched-cmd "Unrecognized command: $1"<br>        ;;<br>esac</li></ul><div>Where should I squeeze in <i>/var/lib/nut/NUT-scripts/</i><i>shutdownrouter.</i>sh?</div></div><div><br></div><div>Thanks for anyone's help!</div><div><br></div><div>Kind regards,</div><div><br></div><div>Erik</div></div>