From 160e5a07beea8cd556c40c8bedda446cf6407828 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 4 Jul 2023 18:20:03 +0200 Subject: [PATCH] feat: Close network on shutdown --- run/network.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/run/network.sh b/run/network.sh index 9ff37b7..2287cc2 100644 --- a/run/network.sh +++ b/run/network.sh @@ -140,7 +140,13 @@ configureNAT () { # QEMU Works with taps, set tap to the bridge created ip tuntap add dev "${VM_NET_TAP}" mode tap - ip link set "${VM_NET_TAP}" up promisc on + + while [ ! ip link set "${VM_NET_TAP}" up promisc on ] + do + info "Waiting for tap to become available..." + sleep 2 + done + ip link set dev "${VM_NET_TAP}" master dockerbridge # Add internet connection to the VM @@ -174,6 +180,19 @@ configureNAT () { return 0 } +closeNetwork () { + + ip link set "${VM_NET_TAP}" down + ip link delete "${VM_NET_TAP}" + + if [[ "${DHCP}" != [Yy1]* ]]; then + + ip link set dockerbridge down + ip link delete dockerbridge + + fi +} + # ###################################### # Configure Network # ######################################