idk a bunch more updates

This commit is contained in:
Anish Lakhwara
2025-11-21 21:06:42 -08:00
parent baa309eb4b
commit 6edf5ecdfc
11 changed files with 182 additions and 34 deletions
+35
View File
@@ -50,5 +50,40 @@ in
];
};
};
# Ensure WireGuard restarts on failure
systemd.services.wireguard-wg0 = {
serviceConfig = {
Restart = "on-failure";
RestartSec = "5s";
};
};
# Periodic connection health check and reconnect
systemd.services.wireguard-wg0-healthcheck = {
description = "WireGuard wg0 connection health check";
after = [ "network-online.target" "wireguard-wg0.service" ];
wants = [ "network-online.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = pkgs.writeShellScript "wg0-healthcheck" ''
# Check if we can ping the WireGuard gateway
if ! ${pkgs.iputils}/bin/ping -c 1 -W 5 10.0.69.1 &>/dev/null; then
echo "WireGuard connection down, restarting..."
${pkgs.systemd}/bin/systemctl restart wireguard-wg0.service
fi
'';
};
};
systemd.timers.wireguard-wg0-healthcheck = {
description = "Timer for WireGuard wg0 health check";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "2min";
OnUnitActiveSec = "2min";
Unit = "wireguard-wg0-healthcheck.service";
};
};
};
}