forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpnutil-stop.sh
executable file
·51 lines (41 loc) · 1.17 KB
/
vpnutil-stop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Based on https://github.com/raycast/script-commands/tree/master/commands/system/vpn
# Dependency: vpnutil https://github.com/Timac/VPNStatus/releases/latest
# Installation:
# 1. Download vpnutil.zip
# 2. Uncompress
# 3. Move vpnutil to /usr/local/bin
# 4. Run manually once to bypass GateKeeper protection:
# - Right-click the app in the Finder
# - Select Open
# - Click on the Open button
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Stop VPN
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 📡
# @Documentation:
# @raycast.packageName VPN
# @raycast.description Stop VPN connection
# @raycast.author Sergey Fuksman
# @raycast.authorURL https://github.com/fuksman
CONFIG=vpnutil-config.sh
if [ ! -f $CONFIG ]; then
echo "Create a vpn-config.sh from template!"
exit 1
fi
# shellcheck source=/dev/null
source $CONFIG
VPN=$VPN_NAME
# Source: https://superuser.com/a/736859
function isnt_connected () {
vpnutil status "$VPN" | sed -n 1p | grep -qv Connected
}
if isnt_connected "$VPN"; then
echo "$VPN isn't connected"
exit 1
else
vpnutil stop "$VPN"
echo "Disconnected from $VPN"
fi