#!/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