feat: Detect empty boot variable (#88)
This commit is contained in:
parent
e9087a6eb3
commit
6ca072aae4
3 changed files with 20 additions and 31 deletions
|
@ -102,19 +102,17 @@ kubectl apply -f kubernetes.yml
|
||||||
|
|
||||||
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.
|
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?
|
* ### How do I boot without SCSI drivers?
|
||||||
|
|
||||||
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.
|
By default, the machine makes use of `virtio-scsi` disks for performance reasons, and even though most Linux kernels include the necessary driver for this device, for some other operating systems that may not always be the case.
|
||||||
|
|
||||||
If your ISO fails to boot because of this, you can add this to your compose file:
|
If your ISO fails to boot because of this, you can modify your compose file to use `virtio-blk` instead:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
DISK_TYPE: "blk"
|
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?
|
* ### How do I boot a x86 image?
|
||||||
|
|
||||||
You can use [qemu-docker](https://github.com/qemus/qemu-docker/) to run x86 and x64 images on ARM.
|
You can use [qemu-docker](https://github.com/qemus/qemu-docker/) to run x86 and x64 images on ARM.
|
||||||
|
|
|
@ -1,41 +1,31 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
file=$(find / -maxdepth 1 -type f -iname boot.iso | head -n 1)
|
iso () {
|
||||||
[ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso | head -n 1)
|
local file="$1"
|
||||||
|
[ ! -f "$file" ] && return 1
|
||||||
|
[ ! -s "$file" ] && return 1
|
||||||
|
|
||||||
if [ ! -s "$file" ] && [[ "${BOOT,,}" != "http"* ]]; then
|
|
||||||
base=$(basename "$BOOT")
|
|
||||||
file="$STORAGE/$base"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$file" ] && [ -s "$file" ]; then
|
|
||||||
BOOT="$file"
|
BOOT="$file"
|
||||||
return 0
|
return 0
|
||||||
fi
|
}
|
||||||
|
|
||||||
if [ -z "$BOOT" ]; then
|
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)
|
||||||
|
iso "$file" && return 0
|
||||||
|
|
||||||
|
if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then
|
||||||
hasDisk && return 0
|
hasDisk && return 0
|
||||||
error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64
|
error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
base=$(basename "$BOOT")
|
base=$(basename "$BOOT")
|
||||||
file="$STORAGE/$base"
|
iso "$STORAGE/$base" && return 0
|
||||||
|
|
||||||
if [ -f "$file" ] && [ -s "$file" ]; then
|
|
||||||
BOOT="$file"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
base=$(basename "${BOOT%%\?*}")
|
base=$(basename "${BOOT%%\?*}")
|
||||||
: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}"
|
: "${base//+/ }"; printf -v base '%b' "${_//%/\\x}"
|
||||||
base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
||||||
file="$STORAGE/$base"
|
iso "$STORAGE/$base" && return 0
|
||||||
|
|
||||||
if [ -f "$file" ] && [ -s "$file" ]; then
|
|
||||||
BOOT="$file"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
TMP="$STORAGE/${base%.*}.tmp"
|
TMP="$STORAGE/${base%.*}.tmp"
|
||||||
rm -f "$TMP"
|
rm -f "$TMP"
|
||||||
|
@ -67,6 +57,7 @@ if ((size<100000)); then
|
||||||
error "Invalid ISO file: Size is smaller than 100 KB" && exit 62
|
error "Invalid ISO file: Size is smaller than 100 KB" && exit 62
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv -f "$TMP" "$file"
|
mv -f "$TMP" "$STORAGE/$base"
|
||||||
|
! iso "$STORAGE/$base" && exit 63
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -328,8 +328,8 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
||||||
|
|
||||||
! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
|
! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
|
||||||
|
|
||||||
if [[ "$GATEWAY" == "172."* ]]; then
|
if [[ "$IP" == "172."* ]]; then
|
||||||
warn "your gateway IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
|
warn "your IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configuration for DHCP IP
|
# Configuration for DHCP IP
|
||||||
|
@ -337,7 +337,7 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
if [[ "$GATEWAY" != "172."* ]] && [[ "$GATEWAY" != "10.8"* ]] && [[ "$GATEWAY" != "10.9"* ]]; then
|
if [[ "$IP" != "172."* ]] && [[ "$IP" != "10.8"* ]] && [[ "$IP" != "10.9"* ]]; then
|
||||||
! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
|
! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue