Skip to content

Commit

Permalink
Add random delay to infomaniak updater
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoriguchi committed Dec 22, 2024
1 parent aef13ec commit f4fb3d4
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions modules/default/infomaniak.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,28 @@ in {
}
];

systemd.services = lib.listToAttrs (map (hostname:
lib.nameValuePair "infomaniak-${lib.replaceStrings [ "." ] [ "-" ] hostname}" {
after = [ "network.target" ];
systemd = {
services = lib.listToAttrs (map (hostname:
lib.nameValuePair "infomaniak-${lib.replaceStrings [ "." ] [ "-" ] hostname}" {
after = [ "network.target" ];

script = ''${pkgs.curl}/bin/curl -s "https://${cfg.username}:${cfg.password}@infomaniak.com/nic/update?hostname=${hostname}"'';
script = ''${pkgs.curl}/bin/curl -s "https://${cfg.username}:${cfg.password}@infomaniak.com/nic/update?hostname=${hostname}"'';

startAt = "*:*:0/5";
serviceConfig = {
DynamicUser = true;
Restart = "on-abort";
};
}) cfg.hostnames);

serviceConfig = {
DynamicUser = true;
Restart = "on-abort";
};
}) cfg.hostnames);
timers = lib.listToAttrs (map (hostname:
lib.nameValuePair "infomaniak-${lib.replaceStrings [ "." ] [ "-" ] hostname}" {
wantedBy = [ "timers.target" ];

timerConfig = {
OnCalendar = "*:0/5";
RandomizedDelaySec = 60;
};
}) cfg.hostnames);
};
};
}

0 comments on commit f4fb3d4

Please sign in to comment.