From 4ce44a47c916f2a0bfd6f88b991f68fce84d493f Mon Sep 17 00:00:00 2001 From: Dinesh Kumar Date: Wed, 10 Oct 2018 20:36:16 +0530 Subject: [PATCH 1/2] Disconnect a vpn --- lazy-connect.sh | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/lazy-connect.sh b/lazy-connect.sh index e1d8531..47b35e5 100755 --- a/lazy-connect.sh +++ b/lazy-connect.sh @@ -63,6 +63,7 @@ lazy-connect - Shell function to fuzzy search an IPSec VPN by name -u - Update lazy-connect -r - Refresh vpn list in ~/.config/lazy-connect -h - Show this help +-d - Disconnect a connected VPN EOF } @@ -105,7 +106,7 @@ function _lazy_connect() { esac fi - osascript <> "$_lazy_connect_config_dir/connected_vpns" +} + +function _lazy_disconnect() { + vpn_name=$1 + + osascript < Date: Thu, 11 Oct 2018 10:19:47 +0530 Subject: [PATCH 2/2] Delete the vpn once disconnected with uniq sort --- lazy-connect.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lazy-connect.sh b/lazy-connect.sh index 47b35e5..43df6d2 100755 --- a/lazy-connect.sh +++ b/lazy-connect.sh @@ -154,9 +154,8 @@ function _lazy_disconnect() { end disconnectVpn disconnectVpn("$vpn_name") - sed "/Connect ${vpn_name}/d" $_lazy_connect_config_dir/vpns - sed "/Disconnect ${vpn_name}/d" $_lazy_connect_config_dir/connected_vpns | sort -u EOF + sed "/Disconnect ${vpn_name}/d" $_lazy_connect_config_dir/connected_vpns | sort -u > $_lazy_connect_config_dir/connected_vpns } function _lazy_connect_update() {