Systemd: opevpn init script

create file /lib/systemd/system/ovpn.service

1
2
3
[Unit]
Description=OpenVPN to home
After=network.target

[Service]
Type=forking
PIDFile=/var/run/ovpn.pid
ExecStart=/usr/sbin/openvpn --daemon --cd /home/alter/ovpn/ --config ovpn.conf
Restart=always
RestartSec=60
ExecStop=killall -9 openvpn

[Install]
WantedBy=default.target

where

1
--cd /home/alter/ovpn/

is a path to folder with ovpn.conf

1
--config ovpn.conf

is a config file of openvpn client.