forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpnutil-status.sh
executable file
·48 lines (37 loc) · 1.08 KB
/
vpnutil-status.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
#!/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 VPN Status
# @raycast.mode inline
# @raycast.refreshTime 30s
# Optional parameters:
# @raycast.icon 📡
# @Documentation:
# @raycast.packageName VPN
# @raycast.description Check 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
status=$(vpnutil status "$VPN" | sed -n 1p | awk 'NF>1{print $NF}')
if [ "$status" == "Connected" ]; then
echo "$status to $VPN"
exit 0
fi
echo "$status"