Unverified Commit 4f6ee091 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Simplify conditional checks (#825)

parent de081dac
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ case "${BOOT_MODE,,}" in
      cp "$OVMF/$VARS" "$DEST.vars"
    fi

    if [[ "${BOOT_MODE,,}" == "secure" ]] || [[ "${BOOT_MODE,,}" == "windows_secure" ]]; then
    if [[ "${BOOT_MODE,,}" == "secure" || "${BOOT_MODE,,}" == "windows_secure" ]]; then
      BOOT_OPTS+=" -global driver=cfi.pflash01,property=secure,value=on"
    fi

@@ -91,7 +91,7 @@ MSRS="/sys/module/kvm/parameters/ignore_msrs"
if [ -e "$MSRS" ]; then
  result=$(<"$MSRS")
  result="${result//[![:print:]]/}"
  if [[ "$result" == "0" ]] || [[ "${result^^}" == "N" ]]; then
  if [[ "$result" == "0" || "${result^^}" == "N" ]]; then
    echo 1 | tee "$MSRS" > /dev/null 2>&1 || true
  fi
fi
+2 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ isCow() {
supportsDirect() {
  local FS=$1

  if [[ "${FS,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then
  if [[ "${FS,,}" == "ecryptfs" || "${FS,,}" == "tmpfs" ]]; then
    return 1
  fi

@@ -550,7 +550,7 @@ addDevice () {
  physical="${physical%% *}"

  if [ -n "$physical" ]; then
    if [[ "$physical" == "512" ]] || [[ "$physical" == "4096" ]]; then
    if [[ "$physical" == "512" || "$physical" == "4096" ]]; then
      if [[ "$physical" == "4096" ]]; then
        sectors=",logical_block_size=$logical,physical_block_size=$physical"
      fi
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ case "${DISPLAY,,}" in
    ;;
esac

if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then
if [[ "$GPU" != [Yy1]* || "$ARCH" != "amd64" ]]; then
  return 0
fi

+9 −9
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ configureDHCP() {
      fi ;;
  esac

  if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
  if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then
    if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
      warn "Failed to set MTU size.."
    fi
@@ -78,7 +78,7 @@ configureDHCP() {
  IFS=: read -r MAJOR MINOR < <(cat /sys/devices/virtual/net/"$VM_NET_TAP"/tap*/dev)
  (( MAJOR < 1)) && error "Cannot find: sys/devices/virtual/net/$VM_NET_TAP" && return 1

  [[ ! -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
    { mknod "$TAP_PATH" c "$MAJOR" "$MINOR" ; rc=$?; } || :
@@ -178,7 +178,7 @@ getHostPorts() {

  [ -z "$list" ] && list="$web" || list+=",$web"

  if [[ "${DISPLAY,,}" == "vnc" ]] || [[ "${DISPLAY,,}" == "web" ]]; then
  if [[ "${DISPLAY,,}" == "vnc" || "${DISPLAY,,}" == "web" ]]; then
    [ -z "$list" ] && list="$vnc" || list+=",$vnc"
  fi

@@ -257,7 +257,7 @@ configureNAT() {
    error "$tuntap" && return 1
  fi

  if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
  if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then
    if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
      warn "Failed to set MTU size.."
    fi
@@ -415,13 +415,13 @@ getInfo() {
  fi

  if [[ "${ADAPTER,,}" != "virtio-net-pci" ]]; then
    if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
    if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then
      warn "MTU size is $MTU, but cannot be set for $ADAPTER adapters!" && MTU="0"
    fi
  fi

  if [[ "${BOOT_MODE:-}" == "windows_legacy" ]]; then
    if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
    if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then
      warn "MTU size is $MTU, but cannot be set for legacy Windows versions!" && MTU="0"
    fi
  fi
@@ -479,7 +479,7 @@ html "Initializing network..."
if [[ "$DEBUG" == [Yy1]* ]]; then
  mtu=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
  line="Host: $HOST  IP: $IP  Gateway: $GATEWAY  Interface: $VM_NET_DEV  MAC: $VM_NET_MAC  MTU: $mtu"
  [[ "$MTU" != "0" ]] && [[ "$MTU" != "$mtu" ]] && line+=" ($MTU)"
  [[ "$MTU" != "0" && "$MTU" != "$mtu" ]] && line+=" ($MTU)"
  info "$line"
  if [ -f /etc/resolv.conf ]; then
    nameservers=$(grep '^nameserver*' /etc/resolv.conf | head -c -1 | sed 's/nameserver //g;' | sed -z 's/\n/, /g')
@@ -506,7 +506,7 @@ if [[ "$DHCP" == [Yy1]* ]]; then

else

  if [[ "$IP" != "172."* ]] && [[ "$IP" != "10.8"* ]] && [[ "$IP" != "10.9"* ]]; then
  if [[ "$IP" != "172."* && "$IP" != "10.8"* && "$IP" != "10.9"* ]]; then
    checkOS
  fi

@@ -540,7 +540,7 @@ else
fi

NET_OPTS+=" -device $ADAPTER,id=net0,netdev=hostnet0,romfile=,mac=$VM_NET_MAC"
[[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]] && NET_OPTS+=",host_mtu=$MTU"
[[ "$MTU" != "0" && "$MTU" != "1500" ]] && NET_OPTS+=",host_mtu=$MTU"

html "Initialized network successfully..."
return 0
+2 −2
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ if [[ "$KVM" != [Nn]* ]]; then
    CPU_FEATURES+=",migratable=no"
  fi

  if [[ "$VMX" == [Nn]* ]] && [[ "${BOOT_MODE,,}" == "windows"* ]]; then
  if [[ "$VMX" == [Nn]* && "${BOOT_MODE,,}" == "windows"* ]]; then
    CPU_FEATURES+=",-vmx"
  fi

@@ -93,7 +93,7 @@ if [[ "$KVM" != [Nn]* ]]; then

  fi

  if [[ "$HV" != [Nn]* ]] && [[ "${BOOT_MODE,,}" == "windows"* ]]; then
  if [[ "$HV" != [Nn]* && "${BOOT_MODE,,}" == "windows"* ]]; then

    HV_FEATURES="hv_passthrough"

Loading