Skip to content

Commit 968ce85

Browse files
committed
Initial commit
0 parents  commit 968ce85

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# vim
2+
*.swp
3+
4+
# osx
5+
.DS_Store

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ipsec-fzf

ipsec-fzf.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#! /bin/bash
2+
3+
function _ipsec_fzf_store_vpn_names() {
4+
vpnNames=$(osascript <<EOF
5+
tell application "System Events"
6+
tell process "SystemUIServer"
7+
set vpnMenu to (menu bar item 1 of menu bar 1 where description is "VPN")
8+
tell vpnMenu to click
9+
set vpnMenuItems to (menu items of menu 1 of vpnMenu)
10+
-- Loop till first missing value(that is fisrt menu item seperator) and accumulate VPN Names
11+
set vpnNames to {}
12+
repeat with vpnMenuItem in vpnMenuItems
13+
set vpnName to name of vpnMenuItem
14+
if vpnName is equal to missing value then
15+
exit repeat
16+
end if
17+
set vpnNames to vpnNames & {vpnName}
18+
end repeat
19+
key code 53
20+
get vpnNames
21+
end tell
22+
end tell
23+
EOF
24+
)
25+
26+
echo $vpnNames | sed -e "s/Connect //g; s/Disconnect //g;" | tr , "\n" | xargs -I{} echo {} > ~/.config/ipsec-fzf/vpns
27+
echo "\nVPNs:"
28+
cat ~/.config/ipsec-fzf/vpns
29+
}
30+
31+
function connect-vpn() {
32+
while getopts "iah" opt; do
33+
case $opt in
34+
h)
35+
echo "Usage"
36+
;;
37+
i)
38+
echo "Secret Key: "
39+
read -s secret_key
40+
echo "**********"
41+
mkdir -p ~/.config/ipsec-fzf
42+
echo $secret_key > ~/.config/ipsec-fzf/secret
43+
_ipsec_fzf_store_vpn_names
44+
;;
45+
a)
46+
echo "Connect all"
47+
;;
48+
\?)
49+
echo "Invalid Option: -$OPTARG."
50+
echo "Usage"
51+
return 1
52+
;;
53+
:)
54+
echo "Option -$OPTARG requires an argument."
55+
echo "Usage"
56+
return 1
57+
;;
58+
esac
59+
done
60+
}

0 commit comments

Comments
 (0)