diff --git a/change-vpn.sh b/change-vpn.sh new file mode 100644 index 0000000..2d9c0ce --- /dev/null +++ b/change-vpn.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +ACTIVE_VPN=`nmcli con show -a | grep 'vpn'` +INACTIVE_VPNS=( $(nmcli con show | grep 'vpn.*-') ) + +VPNS=() + +for index in ${!INACTIVE_VPNS[@]} +do + if [[ ${INACTIVE_VPNS[$index]} == *"VPN-"* ]]; then + VPNS+=(${INACTIVE_VPNS[$index]}) + fi +done + +rand=$[$RANDOM % ${#VPNS[@]}] +NEW_CONNECTION=${VPNS[$rand]} + +nmcli con down $ACTIVE_VPN + +sleep 15 + +nmcli con up $NEW_CONNECTION