Commit d1b93cd5 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

Print more debug info

parent 8509cd0f
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -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=$(</sys/class/net/"${VM_NET_TAP}"/ifindex)
  TAP_PATH="/dev/tap${TAP_NR}"

@@ -108,10 +112,11 @@ configureDHCP() {
configureNAT () {

  VM_NET_IP='20.20.20.21'
  [ "$DEBUG" = "Y" ] && set -x

  #Create bridge with static IP for the VM guest

  { ip link add dev dockerbridge type bridge > /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
}

# ######################################