I have two systemd scripts that I want to run on boot up.
The first systemd script starts OpenVPN, which then executes a shell script that writes the IP of the connection to the file
vpn.env.The second systemd script starts Transmission and should bind to the IP adress in
vpn.env.
My problem seems to be that the execution of the 2nd systemd script is too "quick", and is completed before OpenVPN can start and write vpn.env.
Question: Is there some way to add a delay to the second script, perhaps a few seconds, and have it wait for the environment file to be written?
systemd OpenVPN script
[Unit]
Description=VPN Custom Launch Connection
After=network.target
[Service]
Type=simple
ExecStart=/usr/sbin/openvpn --cd /etc/openvpn --config /etc/openvpn/vpn.conf
[Install]
WantedBy=multi-user.target
OpenVPN .sh script, executed when program starts
printenv > /etc/openvpn/vpn.env
systemd Transmission script
[Unit]
Description=Transmission BitTorrent Daemon Under VPN
After=network.target vpn.service
Requires=vpn.service
[Service]
User=transmission
Type=notify
EnvironmentFile=/etc/openvpn/vpn.env
ExecStart=/usr/bin/transmission-daemon -f --log-error --config-dir /opt/transmission --bind-address-ipv4 $ifconfig_local --rpc-bind-address 0.0.0.0 --no-portmap
ExecReload=/bin/kill -s HUP $MAINPID
[Install]
WantedBy=multi-user.target
OnBootSec=directive (example)