You are not logged in.
I should probably preface this by saying that I'm not a developer.
I'm writing a script that will include a few systemd service files, which I understand require absolute paths to their respective executables. Because I don't know where the user will choose to install the program, I don't know the absolute paths of these executables. I don't want to just assume that they'll be using the /usr/local/ prefix. The only solution that I could come up with would involve an install script that modifies the unit files accordingly, although I was planning on using a makefile to install the program. Is there a best practice regarding how to set ExecStart= in the service files?
Also: Where should I install the unit files? Let's say the user chooses to install in /usr/local/. Should they go in /usr/local/lib/systemd/user/ or /usr/lib/systemd/user/? I know that systemd checks /usr/local/lib/systemd/user/ for unit files, but it may not check wherever else they choose to install to, making /usr/lib/ a safer bet. I'm hesitant to install them under /usr/lib/, however, because I thought that hierarchy was reserved for use with a package manager.
Last edited by thePhysicist8 (2016-07-08 12:38:14)
Offline
man systemd.exec:
ENVIRONMENT VARIABLES IN SPAWNED PROCESSES
Processes started by the system are executed in a clean environment in which select variables listed below are set. System processes started by systemd do not inherit variables
from PID 1, but processes started by user systemd instances inherit all environment variables from the user systemd instance.$PATH
Colon-separated list of directories to use when launching executables. Systemd uses a fixed value of /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.
Is this what you are looking for?
It's not clear what you try to do...
Offline
That's not what I was looking for. Maybe I did a poor job of explaining it the first time.
I understand that processes spawned by the service inherit environment variables like $PATH, but I'm not talking about those processes. I'm talking about calling an executable from the ExecStart= line within the service file itself. While you can use environment variables (such as $PATH) within systemd unit files, that doesn't mean that they can interpret $PATH. Running ${PATH}/my-binary doesn't work in bash because $PATH is just a colon-separated list of directories, and the same goes for unit files. As far as I know, you must use an absolute path for ExecStart=. I'm wondering how I'm supposed to know what that absolute path is when I don't know where the executables are.
Last edited by thePhysicist8 (2016-07-07 12:44:01)
Offline
Configure the service file in your Makefile.
sed 's/@BINDIR@/$(BINDIR)/g' myscript.service.in > myscript.service
Last edited by eschwartz (2016-07-07 14:48:26)
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline