Last active
June 9, 2020 06:06
-
-
Save BillyDonahue/45e9542410b437fa68c04fe99e615946 to your computer and use it in GitHub Desktop.
Create a route to an Evergreen workstation through the selected VPN interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
host="${1:-$(<~/.local/etc/evghost)}" | |
vpn_name="${2:-"mongo vpn"}" | |
cat >&2 <<EOF | |
host: [$host] | |
vpn_name: [$vpn_name] | |
EOF | |
svc="$( | |
scutil --nc list | | |
grep -i "$vpn_name" | | |
sed 's/.* \([^ ]*\) PPP .*/\1/' | |
)" | |
iface="$( | |
scutil <<<"show State:/Network/Service/$svc/IPv4" | | |
awk '/InterfaceName/ { print $3 }')" | |
cat >&2 <<EOF | |
svc: [$svc] | |
iface: [$iface] | |
EOF | |
[[ -n $iface ]] && /sbin/route add -host "$host" -interface "$iface" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment