aubergine: add watch-lte
authorJulien Moutinho <julm+julm-nix@sourcephile.fr>
Thu, 16 Mar 2023 03:58:17 +0000 (04:58 +0100)
committerJulien Moutinho <julm+julm-nix@sourcephile.fr>
Thu, 16 Mar 2023 04:21:02 +0000 (05:21 +0100)
hosts/aubergine/networking/lte.nix

index 4ff31d4ccac8dc8a87ae52875c91ff1ad0b7ae7c..6ce6de38812e03246d3cfd730fe2a351bc6da15a 100644 (file)
@@ -70,6 +70,24 @@ in
       [proxy]
     '';
   };
+  systemd.services.watch-lte = {
+    wantedBy = [ "multi-user.target" ];
+    startAt = "*:0/5"; # every 5 min
+    path = with pkgs; [ inetutils networkmanager ];
+    unitConfig = { StartLimitIntervalSec = 0; };
+    serviceConfig = {
+      Type = "simple";
+      IPAddressAllow = [ "9.9.9.9" ];
+      RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
+      ExecStart = pkgs.writeShellScript "watch-lte" ''
+        set -eux
+        ping -c 1 9.9.9.9 ||
+        nmcli connection up Prixtel
+      '';
+      Restart = "on-failure";
+      RestartSec = "30s";
+    };
+  };
   environment.systemPackages = [
     pkgs.modem-manager-gui
     pkgs.libmbim