1

Trying to create a Desktop File from which I can launch my openvpn connection, but no luck so far.

What I have:

david@david-x1:~/Schreibtisch$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.10
Release:    18.10
Codename:   cosmic

What I did:

Created a shell script that starts the openvpn connection in /home/david/vpn and it looks like this:

    #!/bin/bash
sudo openvpn --config Zurich.ovpn

Permission: -rwxrwxr-x 1 david david 46 Feb 10 23:18 vpnswiss.sh

This is working fine. When I execute the script by typing ./vpnswiss.sh Im asked for the sudo pw and th VPN tunnel will come up.

My Desktop File:

 [Desktop Entry]
Name=VPN CH
Exec=bash -c '/home/david/vpn/vpnswiss.sh'
Icon=/home/david/vpn/vpnswiss.png
Terminal=true
Type=Application
Version=1.0

I also tried

Exec=/home/david/vpn/vpnswiss.sh

or

Exec=bash -c 'sudo openvpn --config Zurich.ovpn' 

but it doesnt work. The Desktop File shows up on my desktop just fine, including the correct icon and when I run other applications for test purposes like for example Exec=firefox or Exec=bash -c 'sudo firefox', it works instantly. But as soon as Im trying to run openvpn, the terminal window just vanishes after I entered the sudo password. The script is not executed "silently", because when I check ifconfig a few seconds later, theres no VPN connection up.

Any ideas on what I am missing here? Thanks a lot in advance!

2
  • i am not familiar with desktop shortcuts but two things come to my mind: first - relative vs absolute paths, second - as soon as the terminal windows closes the openvpn connection / tun device will be closed either. Feb 12, 2019 at 7:28
  • Thanks for pointing out the obvious! It was about the absolute path, of course! Thanks! Feb 13, 2019 at 6:59

1 Answer 1

2

Found the mistake, thanks to the suggestions in AlexOnLinux comment.

Desktop File was good, but in the Script I needed to use the absolute path:

sudo openvpn --config /home/david/vpn/Zurich.ovpn

Thanks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .