diff --git a/machines/vault01/ups.nix b/machines/vault01/ups.nix index badda28..87642ca 100644 --- a/machines/vault01/ups.nix +++ b/machines/vault01/ups.nix @@ -18,12 +18,30 @@ let cmdScript = pkgs.writeShellApplication { name = "upssched-cmd.sh"; - runtimeInputs = with pkgs; [ systemd ]; + runtimeInputs = with pkgs; [ + systemd + msmtp + ]; text = '' case $1 in - shutdown) shutdown now - # TODO : warn - # TODO : warn & log on unknown cmd + shutdown-low) MEANING="Battery is low, shutting down.";; + shutdown-batt) MEANING="On battery for 15min, shutting down.";; + warn-batt) MEANING="Power line faillure, going on battery.";; + warn-comm) MEANING="Communication with the UPS was broken.";; + warn-bypass) MEANING="The UPS is not protecting the server, power line failure would kill $HOSTNAME instantly.";; + *) MEANING="Signal unknown, check configuration.";; + esac + sendmail -i -t <