fix: Network shutdown (#191)
This commit is contained in:
parent
65cea83713
commit
2d56154644
1 changed files with 23 additions and 23 deletions
|
@ -207,7 +207,6 @@ configureNAT() {
|
|||
fi
|
||||
|
||||
# Create a bridge with a static IP for the VM guest
|
||||
|
||||
{ ip link add dev dockerbridge type bridge ; rc=$?; } || :
|
||||
|
||||
if (( rc != 0 )); then
|
||||
|
@ -287,6 +286,22 @@ configureNAT() {
|
|||
return 0
|
||||
}
|
||||
|
||||
closeBridge() {
|
||||
|
||||
local pid="/var/run/dnsmasq.pid"
|
||||
[ -s "$pid" ] && pKill "$(<"$pid")"
|
||||
|
||||
[[ "${NETWORK,,}" == "user"* ]] && return 0
|
||||
|
||||
ip link set "$VM_NET_TAP" down promisc off &> null || true
|
||||
ip link delete "$VM_NET_TAP" &> null || true
|
||||
|
||||
ip link set dockerbridge down &> null || true
|
||||
ip link delete dockerbridge &> null || true
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
closeNetwork() {
|
||||
|
||||
# Shutdown nginx
|
||||
|
@ -298,26 +313,16 @@ closeNetwork() {
|
|||
exec 30<&- || true
|
||||
exec 40<&- || true
|
||||
|
||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
if [[ "$DHCP" != [Yy1]* ]]; then
|
||||
|
||||
closeBridge
|
||||
return 0
|
||||
|
||||
fi
|
||||
|
||||
ip link set "$VM_NET_TAP" down || true
|
||||
ip link delete "$VM_NET_TAP" || true
|
||||
|
||||
else
|
||||
|
||||
local pid="/var/run/dnsmasq.pid"
|
||||
[ -s "$pid" ] && pKill "$(<"$pid")"
|
||||
|
||||
[[ "${NETWORK,,}" == "user"* ]] && return 0
|
||||
|
||||
ip link set "$VM_NET_TAP" down promisc off || true
|
||||
ip link delete "$VM_NET_TAP" || true
|
||||
|
||||
ip link set dockerbridge down || true
|
||||
ip link delete dockerbridge || true
|
||||
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -457,15 +462,10 @@ else
|
|||
# Configure for tap interface
|
||||
if ! configureNAT; then
|
||||
|
||||
closeBridge
|
||||
NETWORK="user"
|
||||
warn "falling back to usermode networking! Performance will be bad and port mapping will not work."
|
||||
|
||||
ip link set "$VM_NET_TAP" down promisc off &> null || true
|
||||
ip link delete "$VM_NET_TAP" &> null || true
|
||||
|
||||
ip link set dockerbridge down &> null || true
|
||||
ip link delete dockerbridge &> null || true
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue