Unverified Commit 053fd9c2 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Add support for hybrid .iso's (#826)

parent 4f6ee091
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -605,7 +605,11 @@ esac
if [ -f "$BOOT" ] && [ -s "$BOOT" ]; then
  case "${BOOT,,}" in
    *".iso" )
        DISK_OPTS+=$(addMedia "$BOOT" "$MEDIA_TYPE" "$BOOT_INDEX" "0x5") ;;
        if [[ "${HYBRID:-}" != [Yy]* ]]; then
          DISK_OPTS+=$(addMedia "$BOOT" "$MEDIA_TYPE" "$BOOT_INDEX" "0x5")
        else
          DISK_OPTS+=$(createDevice "$BOOT" "$DISK_TYPE" "$BOOT_INDEX" "0x5" "raw" "$DISK_IO" "$DISK_CACHE" "" "")
        fi ;;
    *".img" | *".raw" )
        DISK_OPTS+=$(createDevice "$BOOT" "$DISK_TYPE" "$BOOT_INDEX" "0x5" "raw" "$DISK_IO" "$DISK_CACHE" "" "") ;;
    *".qcow2" )
+39 −16
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ moveFile() {
    return 0
  fi

  if [[ "$file" == "/boot.$ext" ]] || [[ "$file" == "/custom.$ext" ]]; then
  if [[ "${file,,}" == "/boot.${ext,,}" || "${file,,}" == "/custom.${ext,,}" ]]; then
    BOOT="$file"
    return 0
  fi
@@ -71,8 +71,8 @@ moveFile() {

detectType() {

  local dir=""
  local file="$1"
  local result=""

  [ ! -f "$file" ] && return 1
  [ ! -s "$file" ] && return 1
@@ -82,25 +82,48 @@ detectType() {
    * ) return 1 ;;
  esac

  if [ -n "$BOOT_MODE" ] || [[ "${file,,}" != *".iso" ]]; then
    ! moveFile "$file" && return 1
    return 0
  if [ -n "$BOOT_MODE" ] || [[ "${file,,}" == *".qcow2" ]]; then
    moveFile "$file" && return 0
    return 1
  fi

  if [[ "${file,,}" == *".iso" ]]; then

    result=$(isoinfo -f -i "$file" 2>/dev/null)

    if [ -z "$result" ]; then
      error "Failed to read ISO file, invalid format!"
      return 1
    fi

  # Automaticly detect UEFI-compatible ISO's
  dir=$(isoinfo -f -i "$file")
    result=$(echo "${result^^}" | grep "^/EFI")

    if [ -z "$result" ]; then

  if [ -n "$dir" ]; then
    dir=$(echo "${dir^^}" | grep "^/EFI")
    if [ -z "$dir" ] && [ -z "$BOOT_MODE" ]; then
      BOOT_MODE="legacy"

    else

      result=$(fdisk -l "$file" 2>/dev/null)

      if [[ "${result^^}" == *"EFI "* ]]; then
        HYBRID="Y"
      fi

    fi

  else
    error "Failed to read ISO file, invalid format!"

    result=$(fdisk -l "$file" 2>/dev/null)

    if [[ "${result^^}" != *"EFI "* ]]; then
      BOOT_MODE="legacy"
    fi

  ! moveFile "$file" && return 1
  return 0
  fi

  moveFile "$file" && return 0
  return 1
}

downloadFile() {
@@ -269,9 +292,9 @@ findFile() {
  return 1
}

findFile "boot" "iso" && return 0
findFile "boot" "img" && return 0
findFile "boot" "raw" && return 0
findFile "boot" "iso" && return 0
findFile "boot" "qcow2" && return 0
findFile "custom" "iso" && return 0

@@ -298,9 +321,9 @@ STORAGE="$STORAGE/$folder"

if [ -d "$STORAGE" ]; then

  findFile "boot" "iso" && return 0
  findFile "boot" "img" && return 0
  findFile "boot" "raw" && return 0
  findFile "boot" "iso" && return 0
  findFile "boot" "qcow2" && return 0
  findFile "custom" "iso" && return 0