From d1b93cd598f0e98e443c9f355f21dc6f0b58bb35 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 2 May 2023 00:10:28 +0200 Subject: [PATCH] Print more debug info --- run/network.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/run/network.sh b/run/network.sh index cf8ab71..7b38064 100644 --- a/run/network.sh +++ b/run/network.sh @@ -25,7 +25,8 @@ configureDHCP() { NETWORK=$(ip -o route | grep "${VM_NET_DEV}" | grep -v default | awk '{print $1}') IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) - { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge > /dev/null 2>&1 ; rc=$?; } || : + [ "$DEBUG" = "Y" ] && set -x + { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge 2> /dev/null ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Capability NET_ADMIN has not been set ($rc/1). Please add the " @@ -41,9 +42,7 @@ configureDHCP() { ip route add "${NETWORK}" dev "${VM_NET_VLAN}" metric 0 ip route add default via "${GATEWAY}" - echo "INFO: Acquiring an IP address via DHCP using MAC address ${VM_NET_MAC}..." - - { ip link add link "${VM_NET_DEV}" name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge > /dev/null 2>&1 ; rc=$?; } || : + { ip link add link "${VM_NET_DEV}" name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge 2> /dev/null ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Capability NET_ADMIN has not been set ($rc/2). Please add the " @@ -55,6 +54,8 @@ configureDHCP() { ip address flush "${VM_NET_DEV}" ip address flush "${VM_NET_TAP}" + echo "INFO: Acquiring an IP address via DHCP using MAC address ${VM_NET_MAC}..." + DHCP_IP=$(dhclient -v "${VM_NET_TAP}" 2>&1 | grep ^bound | cut -d' ' -f3) if [[ "${DHCP_IP}" == [0-9.]* ]]; then @@ -65,6 +66,9 @@ configureDHCP() { ip address flush "${VM_NET_TAP}" + { set +x; } 2>/dev/null + [ "$DEBUG" = "Y" ] && echo + TAP_NR=$( /dev/null 2>&1 ; rc=$?; } || : + { ip link add dev dockerbridge type bridge 2> /dev/null ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Capability NET_ADMIN has not been set ($rc/3). Please add the " @@ -136,9 +141,12 @@ configureNAT () { iptables -A POSTROUTING -t mangle -p udp --dport bootpc -j CHECKSUM --checksum-fill || true fi + { set +x; } 2>/dev/null + [ "$DEBUG" = "Y" ] && echo + #Check port forwarding flag if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then - { sysctl -w net.ipv4.ip_forward=1 > /dev/null 2>&1; rc=$?; } || : + { sysctl -w net.ipv4.ip_forward=1 2> /dev/null ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: IP forwarding is disabled ($rc). Please add the following " echo "docker setting to your container: --sysctl net.ipv4.ip_forward=1" && exit 24 @@ -182,9 +190,13 @@ configureNAT () { fi DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//') - [ "$DEBUG" = "Y" ] && echo "$DNSMASQ $DNSMASQ_OPTS" && echo + + [ "$DEBUG" = "Y" ] && set -x $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} + + { set +x; } 2>/dev/null + [ "$DEBUG" = "Y" ] && echo } # ######################################