diff --git a/openvpn-rotate b/openvpn-rotate index 013803a..7e5a262 100755 --- a/openvpn-rotate +++ b/openvpn-rotate @@ -10,15 +10,17 @@ if [ "$(whoami)" != "root" ]; then exit fi +prior_ovpn_path="$(readlink "${current_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 -ovpn_file=$(shuf -n1 -e ${ovpn_directory}/*) +new_ovpn_path=$(shuf -n1 -e ${ovpn_directory}/*) -# TODO: Also echo previous configuration's name. -echo "Using OpenVPN configuration $(basename "${ovpn_file}" .ovpn)" +echo "OpenVPN is currently connected to $(basename "${prior_ovpn_path}" .ovpn)" +echo "Switching to OpenVPN configuration $(basename "${new_ovpn_path}" .ovpn)" -ln -fs "${ovpn_file}" "${current_ovpn_path}" +ln -fs "${new_ovpn_path}" "${current_ovpn_path}" echo "Restarting OpenVPN service." systemctl restart openvpn