From a0832392b9a9a24cab8473a3d9778c1f627c01c5 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Fri, 2 Aug 2024 19:26:13 +0200 Subject: [PATCH] configure apcupsd server --- configuration.nix | 3 ++- hardware.nix | 33 +++++++++++++++------------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/configuration.nix b/configuration.nix index b68e69c..092bfd6 100644 --- a/configuration.nix +++ b/configuration.nix @@ -61,7 +61,8 @@ nftables.enable = true; firewall.extraInputRules = '' - meta l4proto esp counter accept comment "allow ipsec" + meta l4proto esp counter accept comment "allow IPsec" + ip saddr 192.168.1.0/24 tcp dport apcupsd accept comment "allow UPS from LAN" ''; usePredictableInterfaceNames = false; diff --git a/hardware.nix b/hardware.nix index 79df6bb..e36c762 100644 --- a/hardware.nix +++ b/hardware.nix @@ -38,36 +38,33 @@ UPSTYPE usb UPSCABLE usb NETSERVER on - NISPORT 3551 MINUTES 5 ''; hooks = let - # Send notifications on the Maxwell - # room when something bad happens. + # Send notifications when something bad happens notify = msg: ''${pkgs.maxwell-notify}/bin/notify "UPS: ${msg}"''; in { - changeme = notify "sostituire le batterie"; - battdetach = notify "batterie disconnesse"; - battattach = notify "batterie riconnesse"; - commfailure = notify "connessione persa"; - commok = notify "connessione ristabilita"; - loadlimit = notify "livello batterie critico (5%)"; - runlimit = notify "autonomia batterie critico (5min)"; - doshutdown = notify "inizio sequenza di spegnimento"; - powerout = notify "rete elettrica disconnessa"; - mainsback = notify "rete elettrica riconnessa"; - onbattery = notify "attivate batterie"; - offbattery = notify "disattivate batterie"; - emergency = notify "malfunzionamento batterie, possibile spegnimento!"; + changeme = notify "replace batteries"; + battdetach = notify "batteries disconnected"; + battattach = notify "batteries reconnected"; + commfailure = notify "connection lost"; + commok = notify "connection enstablished"; + loadlimit = notify "critical battery level (5%)"; + runlimit = notify "critical battery life (5min)"; + doshutdown = notify "shutting down!"; + powerout = notify "main power is out"; + mainsback = notify "main power is back"; + onbattery = notify "batteries connected"; + offbattery = notify "batteries disconnected"; + emergency = notify "battery malfunction, possible shutdown!"; }; }; services.smartd = let - # Send a notification on the Maxwell - # when a disk is starting to fail. + # Send a notification when a disk is starting to fail failHook = with pkgs; writeScript "disk-fail-hook" '' #!/bin/sh ${pkgs.maxwell-notify}/bin/notify \