diff --git a/server/configuration.nix b/server/configuration.nix index c2165ea..1608904 100644 --- a/server/configuration.nix +++ b/server/configuration.nix @@ -40,9 +40,12 @@ }; defaults.email = "letsencrypt@bogaledev.ru"; }; - services.openssh = { - enable = true; - settings.PasswordAuthentication = false; + services = { + logind.settings.Login.HandleLidSwitch = "ignore"; + openssh = { + enable = true; + settings.PasswordAuthentication = false; + }; }; sops = { secrets = { diff --git a/server/mods/system.nix b/server/mods/system.nix index 3b53459..0b8f1cd 100644 --- a/server/mods/system.nix +++ b/server/mods/system.nix @@ -20,6 +20,8 @@ services = { network-watchdog = { script = '' + exec {lock_fd}> /run/network.lock + ${pkgs.util-linux}/bin/flock -n $lock_fd || exit if [ ! -e /run/network.failures ] || [ ! -e /run/network.limit ] || \ ${pkgs.curl}/bin/curl --head --max-time 3 https://bogaledev.ru; then limit=3 @@ -29,9 +31,9 @@ failures=$((1+$(cat /run/network.failures))) fi if [ $failures -ge $limit ]; then - echo "<4>restarting network" + echo "<4>Restarting network" systemctl restart NetworkManager.service - sleep 1 + until ${pkgs.iputils}/bin/ping 10.1.0.1 -c 1 -W 1; do sleep 1; done systemctl restart wg-quick-awg0.service [ $limit -lt 360 ] && limit=$((2*$limit)) failures=0 @@ -39,10 +41,7 @@ echo $limit > /run/network.limit echo $failures > /run/network.failures ''; - serviceConfig = { - LogLevelMax = "warning"; - Type = "oneshot"; - }; + serviceConfig.Type = "oneshot"; }; tgbot-send = { script = ''