Move from crontab to systemd timers
This commit is contained in:
+43
-17
@@ -72,14 +72,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
# Fetch the SSL certificates for nginx to use
|
|
||||||
cron = {
|
|
||||||
enable = true;
|
|
||||||
systemCronJobs = [
|
|
||||||
"0 0 1 */2 * cd /etc/certs && tailscale cert vm-gitlab.shire-zebra.ts.net && chown nginx * && systemctl reload nginx"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
gitlab = {
|
gitlab = {
|
||||||
enable = true;
|
enable = true;
|
||||||
backup = {
|
backup = {
|
||||||
@@ -228,17 +220,51 @@ in
|
|||||||
|
|
||||||
# Do not start nginx until we have tailscaled up and running, so it can bind
|
# Do not start nginx until we have tailscaled up and running, so it can bind
|
||||||
# to the 100.* addresses
|
# to the 100.* addresses
|
||||||
systemd.services = {
|
systemd = {
|
||||||
nginx = rec {
|
services = {
|
||||||
after = [ "network-online.target" ];
|
certRefresh =
|
||||||
requires = [ "network-online.target" ];
|
let
|
||||||
wants = after;
|
script = pkgs.writeShellApplication {
|
||||||
serviceConfig = {
|
name = "cert-refresh";
|
||||||
RestartMaxDelaySec = "30s";
|
runtimeInputs = [ pkgs.tailscale ];
|
||||||
RestartSteps = "5";
|
|
||||||
|
text = ''
|
||||||
|
cd /etc/certs
|
||||||
|
tailscale cert vm-gitlab.shire-zebra.ts.net
|
||||||
|
chown nginx ./*
|
||||||
|
systemctl reload nginx
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
script = lib.getExe script;
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "root";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx = rec {
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
requires = [ "network-online.target" ];
|
||||||
|
wants = after;
|
||||||
|
serviceConfig = {
|
||||||
|
RestartMaxDelaySec = "30s";
|
||||||
|
RestartSteps = "5";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
tailscaled.partOf = [ "network-online.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
timers = {
|
||||||
|
"cert-refresh" = {
|
||||||
|
wantedBy = [ "cert-refresh.service" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "monthly";
|
||||||
|
Persistent = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
tailscaled.partOf = [ "network-online.target" ];
|
|
||||||
};
|
};
|
||||||
system.stateVersion = lib.mkForce "24.11";
|
system.stateVersion = lib.mkForce "24.11";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user