Duas alternativas para criar diretórios systemd, geralmente o mais fácil é declarar RuntimeDirectory
no arquivo unitário de seu serviço:
RuntimeDirectory=, RuntimeDirectoryMode=
Takes a list of directory names. If set, one or more directories by the specified names will be created below/run
(for system services) or below $XDG_RUNTIME_DIR (for user services) when the unit is started, and removed when the unit is stopped. The directories will have the access mode specified inRuntimeDirectoryMode=
, and will be owned by the user and group specified inUser=
andGroup=
. Use this to manage one or more runtime directories of the unit and bind their lifetime to the daemon runtime. The specified directory names must be relative, and may not include a "/", i.e. must refer to simple directories to create or remove. This is particularly useful for unprivileged daemons that cannot create runtime directories in /run due to lack of privileges, and to make sure the runtime directory is cleaned up automatically after use.
Ou para diretórios de tempo de execução que exigem configurações mais complexas ou diferentes ou garantias vitalícias, use tmpfiles.d
e
mande seu pacote soltar um arquivo /usr/lib/tmpfiles.d/mydaemon.conf
:
#Type Path Mode UID GID Age Argument
d /run/mydaemon 0755 myuser myuser - -