mirror of
				https://github.com/vdsm/virtual-dsm.git
				synced 2025-11-04 08:54:51 +08:00 
			
		
		
		
	Shellcheck
This commit is contained in:
		
							parent
							
								
									4fe488e913
								
							
						
					
					
						commit
						d90675fcdf
					
				@ -29,16 +29,16 @@ configureDHCP() {
 | 
				
			|||||||
    echo "docker variable to your container: --device=/dev/vhost-net" && exit 85
 | 
					    echo "docker variable to your container: --device=/dev/vhost-net" && exit 85
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  VM_NET_TAP="_VmMacvtap"
 | 
					  VM_NET_TAP="dsm"
 | 
				
			||||||
  echo "Info: Retrieving IP via DHCP using MAC ${VM_NET_MAC}..."
 | 
					  echo "Info: Retrieving IP via DHCP using MAC ${VM_NET_MAC}..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ip l add link eth0 name ${VM_NET_TAP} address ${VM_NET_MAC} type macvtap mode bridge || true
 | 
					  ip l add link eth0 name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge || true
 | 
				
			||||||
  ip l set ${VM_NET_TAP} up
 | 
					  ip l set "${VM_NET_TAP}" up
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ip a flush eth0
 | 
					  ip a flush eth0
 | 
				
			||||||
  ip a flush ${VM_NET_TAP}
 | 
					  ip a flush "${VM_NET_TAP}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DHCP_IP=$( dhclient -v ${VM_NET_TAP} 2>&1 | grep ^bound | cut -d' ' -f3 )
 | 
					  DHCP_IP=$( dhclient -v "${VM_NET_TAP}" 2>&1 | grep ^bound | cut -d' ' -f3 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [[ "${DHCP_IP}" == [0-9.]* ]]; then
 | 
					  if [[ "${DHCP_IP}" == [0-9.]* ]]; then
 | 
				
			||||||
    echo "Info: Retrieved IP ${DHCP_IP} via DHCP"
 | 
					    echo "Info: Retrieved IP ${DHCP_IP} via DHCP"
 | 
				
			||||||
@ -46,12 +46,12 @@ configureDHCP() {
 | 
				
			|||||||
    echo "ERROR: Cannot retrieve IP from DHCP using MAC ${VM_NET_MAC}" && exit 16
 | 
					    echo "ERROR: Cannot retrieve IP from DHCP using MAC ${VM_NET_MAC}" && exit 16
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ip a flush ${VM_NET_TAP}
 | 
					  ip a flush "${VM_NET_TAP}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  TAP_PATH="/dev/tap$(</sys/class/net/${VM_NET_TAP}/ifindex)"
 | 
					  TAP_PATH="/dev/tap$(</sys/class/net/${VM_NET_TAP}/ifindex)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # create dev file (there is no udev in container: need to be done manually)
 | 
					  # create dev file (there is no udev in container: need to be done manually)
 | 
				
			||||||
  IFS=: read MAJOR MINOR < <(cat /sys/devices/virtual/net/${VM_NET_TAP}/tap*/dev)
 | 
					  IFS=: read MAJOR MINOR < <(cat "/sys/devices/virtual/net/${VM_NET_TAP}/tap*/dev")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (( MAJOR < 1)); then
 | 
					  if (( MAJOR < 1)); then
 | 
				
			||||||
     echo "ERROR: Cannot find: sys/devices/virtual/net/${VM_NET_TAP}" && exit 18
 | 
					     echo "ERROR: Cannot find: sys/devices/virtual/net/${VM_NET_TAP}" && exit 18
 | 
				
			||||||
@ -59,13 +59,13 @@ configureDHCP() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  [[ ! -e ${TAP_PATH} ]] && [[ -e /dev0/${TAP_PATH##*/} ]] && ln -s /dev0/${TAP_PATH##*/} ${TAP_PATH}
 | 
					  [[ ! -e ${TAP_PATH} ]] && [[ -e /dev0/${TAP_PATH##*/} ]] && ln -s /dev0/${TAP_PATH##*/} ${TAP_PATH}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [[ ! -e ${TAP_PATH} ]]; then
 | 
					  if [[ ! -e "${TAP_PATH}" ]]; then
 | 
				
			||||||
    if ! mknod ${TAP_PATH} c $MAJOR $MINOR ; then
 | 
					    if ! mknod "${TAP_PATH}" c "$MAJOR" "$MINOR" ; then
 | 
				
			||||||
      echo "ERROR: Cannot mknod: ${TAP_PATH}" && exit 20
 | 
					      echo "ERROR: Cannot mknod: ${TAP_PATH}" && exit 20
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ! exec 30>>$TAP_PATH; then
 | 
					  if ! exec 30>>"$TAP_PATH"; then
 | 
				
			||||||
    echo -n "ERROR: Please add the following docker variables to your container:  "
 | 
					    echo -n "ERROR: Please add the following docker variables to your container:  "
 | 
				
			||||||
    echo "--device=/dev/vhost-net --device-cgroup-rule='c ${MAJOR}:* rwm'" && exit 21
 | 
					    echo "--device=/dev/vhost-net --device-cgroup-rule='c ${MAJOR}:* rwm'" && exit 21
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user