diff --git a/modules/netcup-dns.nix b/modules/netcup-dns.nix index 2052f20..6ec0c40 100644 --- a/modules/netcup-dns.nix +++ b/modules/netcup-dns.nix @@ -64,7 +64,19 @@ in User = "netcup-dns"; Nice = 19; IOSchedulingClass = "idle"; - ExecStart = "${pkgs.python3.withPackages my-python-packages}/bin/netcup-dns"; + + # Create directory `/run/netcup-dns`. + # `netcup-dns` uses it for caching. + # For systemd to create this directory automatically, `PermissionsStartOnly` is required: https://unix.stackexchange.com/questions/354583/how-to-automatically-create-a-runtime-folder-with-a-systemd-service-or-tmpfiles#comment628290_354583 + RuntimeDirectoryMode = "0755"; + RuntimeDirectory = "netcup-dns"; + PermissionsStartOnly = true; + # Since we use `/run/netcup-dns` for caching between subsequent runs of `netcup-dns`, it should be kept and not deleted. + # Man page section `RuntimeDirectoryPreserve`: + # If set to yes, then the directories are not removed when the service is stopped. Note that since the runtime directory /run/ is a mount point of "tmpfs", then for system services the directories specified in RuntimeDirectory= are removed when the system is rebooted. + RuntimeDirectoryPreserve = true; + + ExecStart = "${pkgs.python3.withPackages my-python-packages}/bin/netcup-dns --cache-directory /run/netcup-dns"; }; }; }