Skip to content

Instantly share code, notes, and snippets.

@BillyDonahue
Last active June 9, 2020 06:06
Show Gist options
  • Save BillyDonahue/45e9542410b437fa68c04fe99e615946 to your computer and use it in GitHub Desktop.
Save BillyDonahue/45e9542410b437fa68c04fe99e615946 to your computer and use it in GitHub Desktop.
Create a route to an Evergreen workstation through the selected VPN interface
#!/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