docker-systemctl-replacement icon indicating copy to clipboard operation
docker-systemctl-replacement copied to clipboard

systemctl enable doesn't copy service file to right place.

Open ladyrick opened this issue 2 years ago • 1 comments

When I run

systemctl enable $(readlink -f my_service.service)

The real systemctl command will create a link point to this file on the right place.

But this systemctl will not. You need to place the service file yourself.

ladyrick avatar Jun 27 '23 10:06 ladyrick

Interesting, I did never use it but it is in fact documented.

https://www.freedesktop.org/software/systemd/man/systemctl.html#enable%20UNIT%E2%80%A6

shows "enable UNIT…, enable PATH…" and explains:

This command expects either valid unit names (in which case various unit file directories are automatically searched for unit files with appropriate names), or absolute paths to unit files (in which case these files are read directly). If a specified unit file is located outside of the usual unit file directories, an additional symlink is created, linking it into the unit configuration path, thus ensuring it is found when requested by commands such as start.

This is related to

https://www.freedesktop.org/software/systemd/man/systemctl.html#link%20PATH%E2%80%A6

"link PATH…" Link a unit file that is not in the unit file search path into the unit file search path. This command expects an absolute path to a unit file. The effect of this may be undone with disable. The effect of this command is that a unit file is made available for commands such as start, even though it is not installed directly in the unit search path. The file system where the linked unit files are located must be accessible when systemd is started (e.g. anything underneath /home/ or /var/ is not allowed, unless those directories are located on the root file system).

And in fact "link" is not implemented by systemctl.py either. The link-path would be prerequisite for the enable-path functionality. I don't see any practical use for it but I take patches.

gdraheim avatar Jun 29 '23 00:06 gdraheim