[systemd-devel] environment/configuration in socket unit files

Honza Horak hhorak at redhat.com
Tue Jul 19 10:27:45 PDT 2011


Hi,

I'm creating some systemd unit files for Fedora (currently myslq just 
FYI), but I need to set a socket path in the mydaemon.socket unit file 
according to user's configuration, which is provided by an executable.

My intention is to store the generated configuration into a temporary 
file (/usr/lib/mydaemon/config in the following example), which has 
new-line separated values and thus can be used in EnvironmentFile.

Is it possible to use variables like EnvironmentFile in a socket unit 
files somehow, e.g. like in the following example? systemd doesn't 
complain, but I don't know if it is legal. And what do you thing about 
using a temporary file for storing new-line separated values? Do you 
have a better solution?

mydaemon.socket:
--------------------------------------------
[Unit]
Description=MyDaemon socket

[Service]
EnvironmentFile=-/etc/sysconfig/network
EnvironmentFile=-/etc/sysconfig/mydaemon
EnvironmentFile=-/usr/lib/mydaemon/config
ExecStartPre=/usr/lib/mydaemon/get-config.sh

[Socket]
ListenStream=/var/lib/mysql/mysql.sock

[Install]
WantedBy=sockets.target
--------------------------------------------

Thanks

Regards,

Honza


More information about the systemd-devel mailing list