aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdback <tyler@tdback.net>2025-03-15 14:54:55 -0400
committertdback <tyler@tdback.net>2025-03-15 14:54:55 -0400
commit084574ca488eab23024a61ce59286f11aa8bf83f (patch)
tree6f897cf31668bc7b1d15c6ea0de88100a6e4f52a
parent6e5f4f0ff241d88d40fcfd87565057b76be1d602 (diff)
profiles/upgrade: send additional alert for configuration rebuilds
-rw-r--r--modules/profiles/upgrade/default.nix15
1 files 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')."
'';
};
}