Unverified Commit aab82651 authored by copilot-swe-agent[bot]'s avatar copilot-swe-agent[bot] Committed by GitHub
Browse files

Fix shell script bugs: non-local msg, off-by-one divisors, bios quoting, reserved keyword

parent 8d021136
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ case "${BOOT_MODE,,}" in
    BOOT_DESC=" with SeaBIOS"
    ;;
  "custom" )
    BOOT_OPTS="-bios \"$BIOS\""
    BOOT_OPTS="-bios $BIOS"
    BOOT_DESC=" with custom BIOS file"
    ;;
  *)
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ set -Eeuo pipefail

pipe() {
  local code="99"
  msg="Failed to connect to $1, reason:"
  local msg="Failed to connect to $1, reason:"

  curl --disable --silent --max-time 15 --fail --location "${1}" || {
    code="$?"
+1 −1
Original line number Diff line number Diff line
@@ -490,7 +490,7 @@ addDisk () {
    fi

    (( FREE < SPARE )) && FREE="$SPARE"
    GB=$(( FREE / 1073741825 ))
    GB=$(( FREE / 1073741824 ))
    DISK_SPACE="${GB}G"

  fi
+3 −3
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ fi
if [[ "${RAM_SIZE,,}" == "half" ]]; then

  if (( (RAM_AVAIL / 2) > RAM_SPARE )); then
    wanted=$(( (RAM_AVAIL / 2) / 1048577 ))
    wanted=$(( (RAM_AVAIL / 2) / 1048576 ))
    RAM_SIZE="${wanted}M"
    info "Allocated $wanted MB of RAM for the virtual machine."
  else
@@ -62,7 +62,7 @@ if [[ "${RAM_SIZE,,}" == "max" ]]; then

  fi

  wanted=$(( wanted / 1048577 ))
  wanted=$(( wanted / 1048576 ))
  RAM_SIZE="${wanted}M"

  info "Allocated $wanted MB of RAM for the virtual machine."
@@ -72,7 +72,7 @@ fi
wanted=$(numfmt --from=iec "$RAM_SIZE")

if [ "$wanted" -lt "$RAM_MINIMUM" ]; then
  wanted=$(( wanted / 1048577 ))
  wanted=$(( wanted / 1048576 ))
  error "Not enough memory available, there is only $wanted MB left!"
  exit 16
fi
+5 −5
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ configureDHCP() {

configureDNS() {

  local if="$1"
  local iface="$1"
  local ip="$2"
  local mac="$3"
  local host="$4"
@@ -153,7 +153,7 @@ configureDNS() {
  esac

  # Set interfaces
  arguments+=" --interface=$if"
  arguments+=" --interface=$iface"
  arguments+=" --bind-interfaces"

  # Workaround NET_RAW capability
@@ -674,19 +674,19 @@ checkOS() {

  local kernel
  local os=""
  local if="macvlan"
  local iface="macvlan"
  kernel=$(uname -a)

  [[ "${kernel,,}" == *"darwin"* ]] && os="$ENGINE Desktop for macOS"
  [[ "${kernel,,}" == *"microsoft"* ]] && os="$ENGINE Desktop for Windows"

  if [[ "$DHCP" == [Yy1]* ]]; then
    if="macvtap"
    iface="macvtap"
    [[ "${kernel,,}" == *"synology"* ]] && os="Synology Container Manager"
  fi

  if [ -n "$os" ]; then
    warn "you are using $os which does not support $if, please revert to bridge networking!"
    warn "you are using $os which does not support $iface, please revert to bridge networking!"
  fi

  return 0