pull/14/merge
hllhll 2020-10-10 22:00:45 +03:00 committed by GitHub
commit 6cc4c4a3c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 6 deletions

29
run.sh
View File

@ -45,6 +45,11 @@ function _cleanup() {
elif [[ $LAN_PARENT =~ \. ]] ; then
sudo ip link del dev $LAN_PARENT
fi
echo "* Rolling back ip address for main if"
sudo service dhcpcd start
sudo dhclient -r
test $WIFI_ENABLED = 'false' || echo "* returning $WIFI_PHY to host"
test $WIFI_ENABLED = 'false' || sudo iw phy "$WIFI_PHY" set netns 1
echo -ne "* finished"
}
@ -83,9 +88,11 @@ function _init_network() {
--subnet $LAN_SUBNET \
$LAN_NAME || exit 1
docker network create --driver macvlan \
-o parent=$WAN_PARENT \
$WAN_NAME || exit 1
if [ ! -z "$WAN_PARENT" ]; then
docker network create --driver macvlan \
-o parent=$WAN_PARENT \
$WAN_NAME || exit 1
fi
}
function _set_hairpin() {
@ -124,7 +131,9 @@ function _create_or_start_container() {
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
--sysctl net.ipv6.conf.all.forwarding=1 \
--name $CONTAINER $IMAGE_TAG >/dev/null
docker network connect $WAN_NAME $CONTAINER
if [ ! -z "$WAN_PARENT" ]; then
docker network connect $WAN_NAME $CONTAINER
fi
_gen_config
docker start $CONTAINER
@ -178,14 +187,22 @@ function _prepare_lan() {
sudo ip link add link ${lan_array[0]} name $LAN_PARENT type vlan id ${lan_array[1]}
fi
sudo ip link set $LAN_PARENT master $LAN_IFACE
# Fix: Orignal code assumed pi would fetch new ip address from the openwrt
# The only way it makes sense is when working with the pi as a `workstation` and not as network device.
# Still, this is usable on workstation scenario but the pi should just have a static ip address that is the
# First address of the segment (docker bride takes .1 which will become the `main` ip for the pi)
echo "* Release current IF address make sure dhcpcd does not come back and screw up ips for the host"
sudo service dhcpcd stop
sudo dhclient -r
echo "* Removing eth0 ip address to prevent confusion with docker bridge"
sudo ip addr flush dev eth0
;;
*)
echo "invalid network driver type, must be 'bridge' or 'macvlan'"
exit 1
;;
esac
echo "* getting address via DHCP"
sudo dhcpcd -q $LAN_IFACE
}
function main() {