21

I can launch OpenVPN and point it at the config file and everything works fine, such as:

sudo openvpn /etc/openvpn/myvpn.conf

but when I try start the service with

sudo /etc/init.d/openvpn start

All I get is the output in syslog:

Jun 23 21:02:30 pc systemd[1]: Starting OpenVPN service...
Jun 23 21:02:30 pc systemd[1]: Started OpenVPN service.

But it is lying to me, there is no openvpn service running:

gk@pc:/etc/openvpn$ ps -aux | grep openvpn
gk   15456  0.0  0.0  13688  2128 pts/0    S+   21:18   0:00 grep --color=auto openvpn

No other openvpn processes running. How can I start the service?

I note with some hilarity that inside /lib/systemd/system/openvpn.service there is:

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecReload=/bin/true
WorkingDirectory=/etc/openvpn

I'm pretty sure /bin/true ISNT my openvpn client application. Is this why openvpn client doesn't work from the command line on Ubuntu 15.04?

37

Is this why openvpn client doesn't work from the command line on Ubuntu 15.04?

No. The reason is that you haven't read the commentary at the top of that very unit file, and you are calling a System 5 rc script directly. Do not call System 5 rc scripts directly, especially on a system where System 5 rc isn't used, such as Ubuntu version 15.

Calling them indirectly via the service command is wrong in the case of OpenVPN, too.

OpenVPN is a templatized service under systemd. The services are named openvpn@config.service. So you should be starting your /etc/openvpn/myvpn.conf instance with

systemctl start openvpn@myvpn.service

Further reading

  • Ok, thanks for your answer. I didn't realize Ubuntu is following the fedora way of handling services now. There seems to be very little documentation about starting/stopping services on 15.04. In fact, as hard as I google I can't find any at all. Is it possible somehow to start it with something like "systemctl start openvpn" and not pass in the config name? – user296916 Jun 23 '15 at 18:26
  • systemd newbie here... What is the unit file you are talking about? Is it freedesktop.org/software/systemd/man/systemd.unit.html ? – Jerry Seutter Jun 25 '15 at 17:02
  • It's the one the questioner gives the full pathname to in the question. It has explanatory commentary at its start. – JdeBP Jun 25 '15 at 20:47
  • 4
    Just FYI but there are no comments in either of those files on Ubuntu 15 to give any indication that what I was doing was wrong. There is really very little by way of documentation to indicate that systemctl is the correct method to now use, and in fact there is ample documentation which suggests that /etc/init.d/xxxx should just use systemctl behind the scenes and it should be transparent to the users, so that existing scripts don't all break. – user296916 Jun 30 '15 at 3:03
  • 2
    You have a typo: systemctl start openvpn@myvpn.service should be systemctl start openvpn@myvpn. – Bryan Larsen Dec 9 '15 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.