#!/bin/bash
# upssched-cmd — executed by upssched when a timer fires
# Place at /etc/nut/upssched-cmd on the NUT master host.
# chmod 755 /etc/nut/upssched-cmd
#
# When the earlyshutdown timer fires (UPS on battery for 30s),
# this broadcasts FSD to all connected upsmon slaves.

case "$1" in
    earlyshutdown)
        logger -t upssched "UPS on battery for 30s — triggering FSD to all clients"
        /sbin/upsmon -c fsd
        ;;
    *)
        logger -t upssched "Unknown upssched command: $1"
        ;;
esac
