diff --git a/run/install.sh b/run/install.sh index 2ec823d..5f7815a 100644 --- a/run/install.sh +++ b/run/install.sh @@ -13,6 +13,8 @@ else PROGRESS="--progress=dot:giga" fi +[ "$DEBUG" = "Y" ] && set -x + { wget "$BOOT" -O "$TMP" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || : (( rc != 0 )) && echo "ERROR: Failed to download ${BOOT}, reason: $rc" && exit 60 @@ -27,3 +29,6 @@ fi FILE="$STORAGE/boot.img" mv -f "$TMP" "$FILE" + +{ set +x; } 2>/dev/null +[ "$DEBUG" = "Y" ] && echo 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 } # ###################################### diff --git a/run/run.sh b/run/run.sh index ca81c18..4d1d080 100755 --- a/run/run.sh +++ b/run/run.sh @@ -59,7 +59,7 @@ EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0 -object rng-random,id=rng0,fi ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${MAC_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS}" ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ') -[ "$DEBUG" = "Y" ] && echo "qemu-system-x86_64 ${ARGS}" && echo +[ "$DEBUG" = "Y" ] && set -x set -m ( @@ -67,6 +67,8 @@ set -m ) set +m +{ set +x; } 2>/dev/null + if (( KERNEL > 4 )); then pidwait -F "${_QEMU_PID}" & wait $! else