connectToVPN.sh

#!/bin/bash

# get current dir
DIR=${0%/*}

# read host list from file
HOSTS=$(cd $DIR; ls)

# get host ip
VPN=$(zenity --list --height 400 --column "Name" ${HOSTS})

# check if chosen dir exists
if [ ! -z ${VPN} ]; then
# connect
cd ${DIR}/${VPN}
gnome-terminal -t "${0##*/}: ${VPN}" -e "sudo openvpn ${VPN}.conf"

# run post-connect script
POST_SCRIPT=${DIR}/${VPN}/${VPN}.sh
if [ -f ${POST_SCRIPT} ]; then
sleep 10
gnome-terminal -e "${POST_SCRIPT}"
fi
fi

# list all connections
nmcli con

# start vpn from command line (ubuntu)
nmcli con up id VPN_NAME

# Links
http://www.panticz.de/nmcli