fix: Simplify conditional checks (#304)

This commit is contained in:
Kroese 2025-09-21 15:04:44 +02:00 committed by GitHub
parent 08ac3ab823
commit 733266fd6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 10 deletions

View file

@ -40,13 +40,13 @@ BOOT_OPTS+=" -device isa-applesmc,osk=$osk"
# OVMF
DEST="$STORAGE/$DEST"
if [ ! -s "$DEST.rom" ] || [ ! -f "$DEST.rom" ]; then
[ ! -s "$OVMF/$ROM" ] || [ ! -f "$OVMF/$ROM" ] && error "UEFI boot file ($OVMF/$ROM) not found!" && exit 44
if [ ! -s "$DEST.rom" || ! -f "$DEST.rom" ]; then
[ ! -s "$OVMF/$ROM" || ! -f "$OVMF/$ROM" ] && error "UEFI boot file ($OVMF/$ROM) not found!" && exit 44
cp "$OVMF/$ROM" "$DEST.rom"
fi
if [ ! -s "$DEST.vars" ] || [ ! -f "$DEST.vars" ]; then
[ ! -s "$OVMF/$VARS" ] || [ ! -f "$OVMF/$VARS" ]&& error "UEFI vars file ($OVMF/$VARS) not found!" && exit 45
if [ ! -s "$DEST.vars" || ! -f "$DEST.vars" ]; then
[ ! -s "$OVMF/$VARS" || ! -f "$OVMF/$VARS" ]&& error "UEFI vars file ($OVMF/$VARS) not found!" && exit 45
cp "$OVMF/$VARS" "$DEST.vars"
fi
@ -73,7 +73,7 @@ if [ ! -f "$IMG" ]; then
[ ! -f "$ISO" ] && gzip -dk "$ISO.gz"
if [ ! -f "$ISO" ] || [ ! -s "$ISO" ]; then
if [ ! -f "$ISO" || ! -s "$ISO" ]; then
error "Could not find image file \"$ISO\"." && exit 10
fi

View file

@ -57,7 +57,7 @@ function download() {
downloadLink=$(echo "$info" | grep 'oscdn' | grep 'dmg')
downloadSession=$(echo "$info" | grep 'expires' | grep 'dmg')
if [ -z "$downloadLink" ] || [ -z "$downloadSession" ]; then
if [ -z "$downloadLink" || -z "$downloadSession" ]; then
local code="99"
msg="Failed to connect to the Apple servers, reason:"
@ -201,12 +201,12 @@ generateSerial() {
local file="$STORAGE/$PROCESS.sn"
local file2="$STORAGE/$PROCESS.mlb"
[ -n "$SN" ] && [ -n "$MLB" ] && return 0
[ -n "$SN" && -n "$MLB" ] && return 0
[ -s "$file" ] && SN=$(<"$file")
[ -s "$file2" ] && MLB=$(<"$file2")
SN="${SN//[![:print:]]/}"
MLB="${MLB//[![:print:]]/}"
[ -n "$SN" ] && [ -n "$MLB" ] && return 0
[ -n "$SN" && -n "$MLB" ] && return 0
# Generate unique serial numbers for machine
SN=$(/usr/local/bin/macserial --num 1 --model "${MODEL}" 2>/dev/null)
@ -238,12 +238,12 @@ if [ -z "$VERSION" ]; then
fi
if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then
if [ ! -f "$BASE_IMG" || ! -s "$BASE_IMG" ]; then
STORAGE="$STORAGE/${VERSION,,}"
BASE_IMG="$STORAGE/base.dmg"
if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then
if [ ! -f "$BASE_IMG" || ! -s "$BASE_IMG" ]; then
! install "$VERSION" "$BASE_IMG" && exit 34
fi