I have subscribed to a VPN service and now I have a few .ovpn files, one for each server. What I'd like to do is creating a shell script in which I can select the file to be loaded, and launch that connection. This is my script:
#!/bin/bash
TITLE="Start a VPN Connection"
FOLDER=$HOME"/ovpn/"
CHOICE=$(zenity --file-selection --title="Select your desired VPN config" --filename="$FOLDER" --file-filter="*.ovpn")
VPNFILE=$(basename "$CHOICE")
clear
sudo openvpn --cd "$FOLDER" --config "'$VPNFILE'" --verb 1 --auth-user-pass "auth.txt" --auth-nocache
Now, the problem is that when I launch this script I can select an .ovpn file, but the script crashes because of this error:
Options error: In [CMD-LINE]:1: Error opening configuration file: 'Server-1.ovpn'
If I edit the last line in my script, using echo instead of sudo, I obtain a connection string. If I copy&paste that line and manually run the generated command, the connections starts and works good.
Is there something wrong in trying to open a openvpn connection from a shell script?