diff --git a/openvpn-rotate b/openvpn-rotate index 7e5a262..81158fd 100755 --- a/openvpn-rotate +++ b/openvpn-rotate @@ -11,11 +11,13 @@ if [ "$(whoami)" != "root" ]; then fi prior_ovpn_path="$(readlink "${current_ovpn_path}")" +new_ovpn_path="${prior_ovpn_path}" # TODO: Add the ability to pass arbitrary ovpn files. -# TODO: Remove the current config from the list of choices. -# Choose a random VPN configuration inside /etc/openvpn/ovpn-enabled -new_ovpn_path=$(shuf -n1 -e ${ovpn_directory}/*) +# Choose a random VPN configuration inside /etc/openvpn/ovpn-enabled until a new one is selected. +while [ "${new_ovpn_path}" = "${prior_ovpn_path}" ]; do + new_ovpn_path="$(shuf -n1 -e "${ovpn_directory}"/*)" +done echo "OpenVPN is currently connected to $(basename "${prior_ovpn_path}" .ovpn)" echo "Switching to OpenVPN configuration $(basename "${new_ovpn_path}" .ovpn)"