dyn-dns: better implementation
This commit is contained in:
@@ -86,7 +86,8 @@ in
|
|||||||
echo "UPNP changed $oldUpnp -> $newUpnp"
|
echo "UPNP changed $oldUpnp -> $newUpnp"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $(test -f '${cfg.ipPath}' -a '${cfg.upnpPath}')
|
exit $(test -f '${cfg.ipPath}')
|
||||||
|
# exit $(test -f '${cfg.ipPath}' -a -f '${cfg.upnpPath}')
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,27 +96,33 @@ in
|
|||||||
timerConfig.OnUnitInactiveSec = cfg.interval;
|
timerConfig.OnUnitInactiveSec = cfg.interval;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.targets.dyn-dns-valid = {
|
systemd.targets.dyn-dns-exists = {
|
||||||
description = "active while dyn dns data exists, and is restarted whenever dyn dns data changes";
|
# consumers depend directly on this target for permission to *start*
|
||||||
wants = [ "dyn-dns.service" ]; #< restarts of this unit *shouldn't* be propagated to dyn-dns.service
|
# once active, this target should never de-activate
|
||||||
|
description = "initial acquisition of dynamic DNS data";
|
||||||
|
wants = [ "dyn-dns.service" ];
|
||||||
after = [ "dyn-dns.service" ];
|
after = [ "dyn-dns.service" ];
|
||||||
requiredBy = cfg.restartOnChange; #< requiredBy will propagate restarts (and explicit stops, but not starts)
|
wantedBy = cfg.restartOnChange;
|
||||||
before = cfg.restartOnChange;
|
before = cfg.restartOnChange;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.paths.dyn-dns-changed = {
|
systemd.targets.dyn-dns-events = {
|
||||||
description = "react to new dynamic DNS data, and if the address changed then propagate that out";
|
# consumers depend on this to be restarted whenever DNS changes (after acquisition)
|
||||||
wants = [ "dyn-dns.service" ];
|
description = "event system that notifies via restart whenever dynamic DNS mapping changes";
|
||||||
after = [ "dyn-dns.service" ];
|
requiredBy = cfg.restartOnChange;
|
||||||
wantedBy = [ "dyn-dns-valid.target" ];
|
# before = cfg.restartOnChange;
|
||||||
before = [ "dyn-dns-valid.target" ];
|
|
||||||
pathConfig.PathChanged = [ cfg.ipPath ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.paths.dyn-dns-changed = {
|
||||||
|
wantedBy = cfg.restartOnChange;
|
||||||
|
wants = [ "dyn-dns-exists.target" ];
|
||||||
|
after = [ "dyn-dns-exists.target" ];
|
||||||
|
pathConfig.PathChanged = [ cfg.ipPath ];
|
||||||
|
};
|
||||||
systemd.services.dyn-dns-changed = {
|
systemd.services.dyn-dns-changed = {
|
||||||
description = "called when dynamic DNS address changes, to restart all listeners";
|
description = "dynamic DNS change notifier";
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig.Type = "oneshot";
|
||||||
serviceConfig.ExecStart = "${lib.getExe' pkgs.systemd "systemctl"} restart dyn-dns-valid.target";
|
serviceConfig.ExecStart = "${lib.getExe' pkgs.systemd "systemctl"} restart dyn-dns-events.target";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user