[systemd-devel] %i/%I instance expansion in ExecStartPre ?

darx at sent.com darx at sent.com
Wed May 1 08:29:57 PDT 2013


Hi,

I've a systemd unit file for my own instance of openvpn

vi /etc/systemd/system/openvpn at .service
	------------------------------------------
	[Unit]
	Description=OpenVPN Server on %I
	After=syslog.target network.target
	Before=openvpn.%i.target

	[Service]
	PrivateTmp=true

	Type=forking
	PIDFile=/var/run/openvpn/%i.pid
	ExecStartPre=/etc/openvpn/up.openvpn_instance_A.service.script
	ExecStart=/sbin/openvpn \
	          --daemon \
	          --writepid /var/run/openvpn/%i.pid \
	          --cd /etc/openvpn/ \
	          --config %i.conf

	[Install]
	WantedBy=multi-user.target
	------------------------------------------

where

	ls -al /etc/openvpn/up.openvpn_instance_A.service.script 
		-rwxrwxr-x+ 1 nobody nobody 77 May  1 07:45
		/etc/openvpn/up.openvpn_instance_A.service.script*


If I enable the service instance

	ln -s \
	 /etc/systemd/system/openvpn\@.service \
	 /etc/systemd/system/multi-user.target.wants/openvpn\@openvpn_instance_A.service
	systemctl enable openvpn at openvpn_instance_A.service

and launch it

	systemctl --system daemon-reload
	systemctl start  openvpn at openvpn_instance_A.service

everything's OK.

But if I change in the service file from a hard-coded path,

	-      
	ExecStartPre=/etc/openvpn/up.openvpn_instance_A.service.script

to either an expansion with

	+       ExecStartPre=/etc/openvpn/up.%i.servicescript

or

	+       ExecStartPre=/etc/openvpn/up.%I.service.script


and again launch it

	systemctl --system daemon-reload
	systemctl start  openvpn at openvpn_instance_A.service

it fails to launch with

	May  1 08:14:53 test systemd[1]: Reloading.
	May  1 08:14:56 test systemd[1]: Starting OpenVPN Server on
	openvpn_instance_A...
	May  1 08:14:56 test systemd[29078]: Failed at step EXEC
	spawning /etc/openvpn/up.%i.service.script: No such file or
	directory
	May  1 08:14:56 test systemd[1]:
	openvpn at openvpn_instance_A.service: control process exited,
	code=exited status=203
	May  1 08:14:56 test systemd[1]: Failed to start OpenVPN Server
	on openvpn_instance_A.
	May  1 08:14:56 test systemd[1]: Unit
	openvpn at openvpn_instance_A.service entered failed state

Is %i/%I expansion in ExecStartPre possible? and/or have I misconfigured
something here?

fyi,

systemctl --version
	systemd 195
	suse
	+PAM +LIBWRAP +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP
	+GCRYPT +ACL +XZ

--darx


More information about the systemd-devel mailing list