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

fix: Simplify conditional checks (#304)

parent 08ac3ab8
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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

+5 −5
Original line number Diff line number Diff line
@@ -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