diff --git a/readme.md b/readme.md index f83ff58..7885557 100644 --- a/readme.md +++ b/readme.md @@ -91,7 +91,7 @@ kubectl apply -f kubernetes.yml This can also be used to resize the existing disk to a larger capacity without any data loss. -* ### How do I boot a local image? +* ### How do I boot a local ISO? You can use a local file directly, and skip the download altogether, by binding it in your compose file in this way: @@ -100,7 +100,20 @@ kubectl apply -f kubernetes.yml - /home/user/example.iso:/boot.iso ``` - Replace the example path `/home/user/example.iso` with the filename of the desired ISO file. + Replace the example path `/home/user/example.iso` with the filename of the desired ISO file, the value of `BOOT` will be ignored in this case. + +* ### How do I boot without SCSI support? + + By default, the machine makes use of `virtio-scsi` disks for performance reasons, and even though most Linux kernels include drivers for them, there are other operating systems that do not. + + If your ISO fails to boot because of this, you can add this to your compose file: + + ```yaml + environment: + DISK_TYPE: "blk" + ``` + + This will use `virtio-blk` devices instead. If it still fails to boot, you can set the value to `ide` or `usb` at the cost of performance. * ### How do I boot a x86 image? diff --git a/src/boot.sh b/src/boot.sh index 0531414..c3598ad 100644 --- a/src/boot.sh +++ b/src/boot.sh @@ -6,6 +6,7 @@ set -Eeuo pipefail BOOT_OPTS="" BOOT_DESC="" +DRIVER_TYPE="usb" SECURE=",secure=off" DIR="/usr/share/qemu" diff --git a/src/disk.sh b/src/disk.sh index 50bd719..9fd45f8 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -514,7 +514,6 @@ case "${DISK_TYPE,,}" in * ) error "Invalid DISK_TYPE, value \"$DISK_TYPE\" is unrecognized!" && exit 80 ;; esac -DRIVER_TYPE="usb" MEDIA_TYPE="$DISK_TYPE" if [ -f "$BOOT" ] && [ -s "$BOOT" ]; then diff --git a/src/install.sh b/src/install.sh index 6cac43e..24e1221 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1,6 +1,45 @@ #!/usr/bin/env bash set -Eeuo pipefail +file=$(find / -maxdepth 1 -type f -iname boot.iso | head -n 1) +[ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso | head -n 1) + +if [ ! -s "$file" ] && [[ "${BOOT,,}" != "http"* ]]; then + base=$(basename "$BOOT") + file="$STORAGE/$base" +fi + +if [ -f "$file" ] && [ -s "$file" ]; then + BOOT="$file" + return 0 +fi + +if [ -z "$BOOT" ]; then + hasDisk && return 0 + error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64 +fi + +base=$(basename "$BOOT") +file="$STORAGE/$base" + +if [ -f "$file" ] && [ -s "$file" ]; then + BOOT="$file" + return 0 +fi + +base=$(basename "${BOOT%%\?*}") +: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}" +base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g') +file="$STORAGE/$base" + +if [ -f "$file" ] && [ -s "$file" ]; then + BOOT="$file" + return 0 +fi + +TMP="$STORAGE/${base%.*}.tmp" +rm -f "$TMP" + # Check if running with interactive TTY or redirected to docker log if [ -t 1 ]; then progress="--progress=bar:noscroll" @@ -8,36 +47,11 @@ else progress="--progress=dot:giga" fi -file="/boot.iso" && [ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0 -file="/boot.img" && [ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0 - -file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso -printf "%f\n" | head -n 1) -[ -z "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.img -printf "%f\n" | head -n 1) -[ -n "$file" ] && file="$STORAGE/$file" -[ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0 - -if [ -z "$BOOT" ]; then - error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64 -fi - -base=$(basename "$BOOT") -[ -n "$base" ] && file="$STORAGE/$base" -[ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0 - -base=$(basename "${BOOT%%\?*}") -: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}" -base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g') -[ -n "$base" ] && file="$STORAGE/$base" -[ -f "$file" ] && [ -s "$file" ] && BOOT="$file" && return 0 - -TMP="$STORAGE/${base%.*}.tmp" -rm -f "$TMP" - msg="Downloading $base..." info "$msg" && html "$msg" /run/progress.sh "$TMP" "" "Downloading $base ([P])..." & -{ wget "$BOOT" -O "$TMP" -q --timeout=10 --show-progress "$progress"; rc=$?; } || : +{ wget "$BOOT" -O "$TMP" -q --timeout=30 --show-progress "$progress"; rc=$?; } || : fKill "progress.sh" diff --git a/src/reset.sh b/src/reset.sh index 2228f38..65bb76f 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -191,6 +191,17 @@ addPackage() { return 0 } +hasDisk() { + + [ -b "/disk1" ] && return 0 + [ -b "/dev/disk1" ] && return 0 + [ -b "${DEVICE:-}" ] && return 0 + [ -s "$STORAGE/data.img" ] && return 0 + [ -s "$STORAGE/data.qcow2" ] && return 0 + + return 1 +} + # Start webserver cp -r /var/www/* /run/shm html "Starting $APP for Docker..."