From 00b1e86279ec1663cda56b1d9199edae17fd821c Mon Sep 17 00:00:00 2001 From: Andrew Klapp Date: Sun, 13 May 2018 20:44:10 -0500 Subject: [PATCH] Now echoes previous VPN name. --- openvpn-rotate | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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