From 084574ca488eab23024a61ce59286f11aa8bf83f Mon Sep 17 00:00:00 2001 From: tdback Date: Sat, 15 Mar 2025 14:54:55 -0400 Subject: profiles/upgrade: send additional alert for configuration rebuilds --- modules/profiles/upgrade/default.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/profiles/upgrade/default.nix b/modules/profiles/upgrade/default.nix index 31de7a2..bde99d7 100644 --- a/modules/profiles/upgrade/default.nix +++ b/modules/profiles/upgrade/default.nix @@ -17,9 +17,8 @@ allowReboot = true; }; - systemd.services."reboot-alert" = + systemd.services."server-monitor" = let - hostname = config.networking.hostName; dependencies = [ "network-online.target" ]; in { @@ -28,8 +27,16 @@ after = dependencies; serviceConfig.Type = "oneshot"; script = '' - /run/current-system/sw/bin/pushover -t "${hostname} restarted" \ - "${hostname} has restarted on $(date '+%a, %b %d at %T %p %Z')." + ACTION="restarted" + + # If a system has been up for *at least* 90 seconds, make the assumption + # that the system's configuration was rebuilt and activated. + if [ "$(cat /proc/uptime | cut -f1 -d.)" -gt 90 ]; then + ACTION="activated a new configuration" + fi + + /run/current-system/sw/bin/pushover -t "${config.networking.hostName}" \ + "Server $ACTION on $(date '+%a, %b %d at %T %p %Z')." ''; }; } -- cgit v1.2.3