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

feat: Default to UEFI for external images (#566)

parent 6abc58e0
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ RUN set -eu && \
        wget \
        7zip \
        ovmf \
        fdisk \
        nginx \
        swtpm \
        procps \
+11 −12
Original line number Diff line number Diff line
@@ -2,10 +2,9 @@
set -Eeuo pipefail

# Docker environment variables
: "${BIOS:=""}"             # BIOS file
: "${TPM:="N"}"         # Disable TPM
: "${SMM:="N"}"         # Disable SMM
: "${BIOS:=""}"             # BIOS file
: "${BOOT_MODE:="legacy"}"  # Boot mode

BOOT_DESC=""
BOOT_OPTS=""
@@ -14,24 +13,24 @@ SECURE="off"
[[ "$SMM" == [Yy1]* ]] && SECURE="on"

if [ -n "$BIOS" ]; then
  BOOT_MODE="custom"
  BOOT_OPTS="-bios $BIOS"
  BOOT_DESC=" with custom BIOS file"
  return 0
fi

case "${BOOT_MODE,,}" in
  "windows"* )
if [[ "${BOOT_MODE,,}" == "windows"* ]]; then
  BOOT_OPTS="-rtc base=localtime"
  BOOT_OPTS+=" -global ICH9-LPC.disable_s3=1"
  BOOT_OPTS+=" -global ICH9-LPC.disable_s4=1"
    ;;
esac
fi

case "${BOOT_MODE,,}" in
  "legacy" )
    BOOT_OPTS=""
    BOOT_DESC=" with SeaBIOS"
    ;;
  "uefi" )
    BOOT_DESC=" with OVMF"
  "uefi" | "" )
    BOOT_MODE="uefi"
    ROM="OVMF_CODE_4M.fd"
    VARS="OVMF_VARS_4M.fd"
    ;;
+11 −30
Original line number Diff line number Diff line
@@ -11,42 +11,23 @@ detectType() {

  case "${file,,}" in
    *".iso" | *".img" | *".raw" | *".qcow2" )
      BOOT="$file"
      [ -n "${BOOT_MODE:-}" ] && return 0 ;;
      BOOT="$file" ;;
    * ) return 1 ;;
  esac

  # Automaticly detect UEFI-compatible images

  case "${file,,}" in
    *".iso" )
  [ -n "$BOOT_MODE" ] && return 0
  [[ "${file,,}" != *".iso" ]] && return 0

  # Automaticly detect UEFI-compatible ISO's
  dir=$(isoinfo -f -i "$file")

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

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

    *".img" | *".raw" )

      dir=$(sfdisk -l "$file")
      if [ -z "$dir" ]; then
        BOOT="" 
        error "Failed to read disk image file, invalid format!" && return 1
      fi

      dir=$(echo "${dir^^}" | grep "EFI SYSTEM")
      [ -n "$dir" ] && BOOT_MODE="uefi" ;;

    *".qcow2" )

      # TODO: Detect boot mode from partition table in image
      BOOT_MODE="uefi" ;;

  esac
  [ -z "$dir" ] && BOOT_MODE="legacy"

  return 0
}
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ echo "❯ For support visit $SUPPORT"
: "${RAM_SIZE:="1G"}"     # Maximum RAM amount
: "${RAM_CHECK:="Y"}"     # Check available RAM
: "${DISK_SIZE:="16G"}"   # Initial data disk size
: "${BOOT_MODE:=""}"      # Boot system with UEFI
: "${BOOT_INDEX:="9"}"    # Boot index of CD drive

# Helper variables