added tailscaled restart if needed

This commit is contained in:
mc-fucker 2025-11-26 23:50:59 +01:00
parent 47160a6a87
commit b9a0677d7e
2 changed files with 34 additions and 9 deletions

View file

@ -50,7 +50,6 @@ in
# enable = true; # enable = true;
#}; #};
users.defaultUserShell = pkgs.zsh; users.defaultUserShell = pkgs.zsh;
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;
@ -69,8 +68,6 @@ in
extraConfig = "ClientAliveInterval 60"; extraConfig = "ClientAliveInterval 60";
}; };
tailscale.enable = true;
fail2ban = { fail2ban = {
enable = true; enable = true;
ignoreIP = ignoreIP =
@ -82,11 +79,6 @@ in
atd.enable = true; atd.enable = true;
}; };
networking.firewall = {
trustedInterfaces = [ "tailscale0" ];
allowedUDPPorts = [ config.services.tailscale.port ];
};
networking.hosts = { networking.hosts = {
"100.64.0.2" = [ "mc-fucker.cool" ]; "100.64.0.2" = [ "mc-fucker.cool" ];
}; };
@ -128,9 +120,10 @@ in
boot.tmp.cleanOnBoot = true; boot.tmp.cleanOnBoot = true;
imports = [ imports = [
./zabbix-agent.nix #./zabbix-agent.nix
./sops.nix ./sops.nix
./ssh-knownHosts.nix ./ssh-knownHosts.nix
./tailscale.nix
]; ];
} }
# vim: set et ts=2 sw=2 ai: # vim: set et ts=2 sw=2 ai:

32
modules/tailscale.nix Normal file
View file

@ -0,0 +1,32 @@
{ config, pkgs, ... }:
{
services = {
tailscale.enable = true;
};
systemd.services."restart-tailscaled" = {
description = "Restart tailscaled if there's an error";
serviceConfig = {
Type = "oneshot";
ExecStart = ''/bin/sh -c "tailscale status --json | jq -e '.Health[]' && systemctl restart tailscaled.service || echo 'No health problem detected'"'';
};
path = with pkgs; [
jq
tailscale
];
};
systemd.timers."restart-tailscaled" = {
timerConfig = {
OnCalendar = "minutely";
};
wantedBy = [ "tailscaled.service" ];
};
networking.firewall = {
trustedInterfaces = [ "tailscale0" ];
allowedUDPPorts = [ config.services.tailscale.port ];
};
}
# vim: set et ts=2 sw=2 ai: