1#!/bin/sh
2# Brings up the tunnel to Snow Globe, the guest's only way off this Mac.
3set -eu
4D=/usr/local/libexec/ext-wg
5gw=$(route -n get default | awk '/gateway:/ {print $2}')
6rm -f /var/run/ext-wg.name
7WG_TUN_NAME_FILE=/var/run/ext-wg.name "$D/wireguard-go" -f utun &
8pid=$!
9trap 'kill $pid' TERM INT
10until [ -s /var/run/ext-wg.name ]; do sleep 0.2; done
11if=$(cat /var/run/ext-wg.name)
12"$D/wg" setconf "$if" /etc/ext-wg.conf
13ifconfig "$if" inet 10.100.0.2 10.100.0.2 netmask 255.255.255.255 mtu 1200 up
14route -q -n add -host 100.64.0.1 "$gw"
15route -q -n add -inet 10.100.0.0/24 -interface "$if"
16route -q -n add -inet 0.0.0.0/1 -interface "$if"
17route -q -n add -inet 128.0.0.0/1 -interface "$if"
18wait $pid