I have written a systemd file to start my VPN Service using a particular configuration file. What I would like to be able to do is have this file replaced with a randomly selected configuration file each time the service starts.
So far i have tried using
ExecStartPre=cp -f `ls /etc/openvpn/ovpn_udp/au* | shuf -n 1` /etc/openvpn/%i.conf
to copy the randomly picked file to the specified configuration file. Some alternativly I have tried are
- used rsync -c instead of cp
- double quotes around the whole ExecStartPre command
- escaping the `
Finally I have also tried the following ExecStart to
ExecStart=/usr/sbin/openvpn --config `ls /etc/openvpn/ovpn_udp/au* | shuf -n 1`
All with no effect.
Currently the systemd file is as follows
[Unit] Description=OpenVPN Robust And Highly Flexible Tunneling Application On %I After=network.target [Service] Type=notify PrivateTmp=true ExecStartPre=cp -f `ls /etc/openvpn/ovpn_udp/au* | shuf -n 1` /etc/openvpn/%i.conf ExecStart=/usr/sbin/openvpn --config /etc/openvpn/%i.conf [Install] WantedBy=multi-user.target
I am expecting the configuration file to be changed before each start of the service but so far I don't see any errors or the configuration file being replaced.
Any help will be greatly appreciated.