[systemd-devel] script assigned via Unit's ExecStartPre= only partially executes, fails to complete ?

Lennart Poettering lennart at poettering.net
Tue Dec 10 13:02:51 PST 2013


On Sun, 01.12.13 00:10, jen142 at promessage.com (jen142 at promessage.com) wrote:

> I'm using an openvpn unit,
> 
> 	cat openvpn.service
> 		[Unit]
> 		Description=OpenVPN
> 		After=syslog.target network.target
> 		Before=openvpn.target
> 
> 		[Service]
> 		PrivateTmp=true
> 		Environment=PATH="/usr/local/openvpn-unpriv:$PATH"

Unit files are not shell. This won't work.

> with the ExecStartPre= script,
> 
> 	cat /usr/local/etc/openvpn/up.script
> 
> 		#!/bin/sh
> 		/usr/local/sbin/openvpn --rmtun --dev tun1 > /dev/null
> 		2>&1
> 		/usr/local/sbin/openvpn --mktun --dev tun1 --dev-type
> 		tun --user openvpn --group openvpn
> 		/usr/sbin/iptables -I FORWARD -i eth0 -o tun1 -j ACCEPT
> 		/usr/sbin/iptables -I FORWARD -i tun1 -o eth0 -j ACCEPT

I am not sure what thos openvpn calls do. If they fork something in the
background, please be aware that systemd will kill that before
proceeding.

Maybe there's a race bewteen the openvpn and iptables commands in that
the interfaces are not finished creating when iptables is started and
then not found.

To debug this further use "set -x" or so, to make your shell log
whatever it does. systemd will pick that up and forward it to syslog.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list