Add support for LOCAL_NETWORK environment variable

This commit is contained in:
Jordan Potter 2021-03-06 21:22:10 -06:00
parent 2ec89350db
commit 42edf25751

View file

@ -2,6 +2,12 @@
set -e set -e
default_route_ip=$(ip route | grep default | awk '{print $3}')
if [[ -z "$default_route_ip" ]]; then
echo "No default route configured" >&2
exit 1
fi
configs=`find /etc/wireguard -type f -printf "%f\n"` configs=`find /etc/wireguard -type f -printf "%f\n"`
if [[ -z "$configs" ]]; then if [[ -z "$configs" ]]; then
echo "No configuration files found in /etc/wireguard" >&2 echo "No configuration files found in /etc/wireguard" >&2
@ -31,6 +37,11 @@ else
ip6tables -I OUTPUT ! -o $interface -m mark ! --mark $(wg show $interface fwmark) -m addrtype ! --dst-type LOCAL $docker6_network_rule -j REJECT ip6tables -I OUTPUT ! -o $interface -m mark ! --mark $(wg show $interface fwmark) -m addrtype ! --dst-type LOCAL $docker6_network_rule -j REJECT
fi fi
if [[ "$LOCAL_NETWORK" ]]; then
ip route add $LOCAL_NETWORK via $default_route_ip
iptables -I OUTPUT -d $LOCAL_NETWORK -j ACCEPT
fi
shutdown () { shutdown () {
wg-quick down $interface wg-quick down $interface
exit 0 exit 0