From 7d6e5b30d872a3e8fdc65099ed691dadabc46220 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sat, 6 Mar 2021 17:59:03 +0000 Subject: [PATCH] Remove useless case statements. Allow -e HEADLESS=true as human readable alternative to -e DISPLAY=:99. --- CHANGELOG.md | 2 +- Dockerfile | 12 ------------ Dockerfile.auto | 17 ++++------------- Dockerfile.naked | 10 +++------- 4 files changed, 8 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e4dc56..ec5dc2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ |Version|Date|Notes| |---|---|---| -| |2021-03-06|Change envs to require --envs. Automatically enable --envs if --output-env is used. Same for plists, bootdisks. Fix help ugliness and sanity of generate serial scripts. Fix bootdisk not getting written to persistent file when using NOPICKER=true. NOPICKER=true is overridden by a custom plist now anyway.| +| |2021-03-06|Change envs to require --envs. Automatically enable --envs if --output-env is used. Same for plists, bootdisks. Fix help ugliness and sanity of generate serial scripts. Fix bootdisk not getting written to persistent file when using NOPICKER=true. NOPICKER=true is overridden by a custom plist now anyway. Remove useless case statements. Allow -e HEADLESS=true as human readable alternative to -e DISPLAY=:99.| |4.1|2021-03-04|Add `-e MASTER_PLIST_URL` to all images to allow using your own remote plist.| | |2021-03-03|Add `WIDTH` and `HEIGHT` to set the x and y resolutions, use in conjuction with serial numbers.| | |2021-03-02|Add ADDITIONAL_PORTS, for example `-e ADDITIONAL_PORTS='hostfwd=tcp::23-:23,'`| diff --git a/Dockerfile b/Dockerfile index 552f449..099fa61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -298,12 +298,6 @@ VOLUME ["/tmp/.X11-unix"] # And the default serial numbers CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ - ; case "$(file --brief /image)" in \ - QEMU\ QCOW2\ Image* ) export IMAGE_PATH=/image \ - ;; \ - directory* ) export IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img \ - ;; \ - esac \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ && export BOOTDISK="${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ @@ -332,12 +326,6 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; case "$(file --brief /bootdisk)" in \ - QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ - ;; \ - directory* ) export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 \ - ;; \ - esac \ ; ./enable-ssh.sh && envsubst < ./Launch.sh | bash # virt-manager mode: eta son diff --git a/Dockerfile.auto b/Dockerfile.auto index 4b186f4..90bb432 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -133,6 +133,8 @@ ENV BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2 ENV DISPLAY=:99 +ENV HEADLESS=false + ENV ENV=/env ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img @@ -175,21 +177,10 @@ CMD echo "${BOILERPLATE}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; case "$(file --brief /bootdisk)" in \ - QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ - ;; \ - directory* ) export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 \ - ;; \ - esac \ - ; [[ "${DISPLAY}" = ':99' ]] && { \ + ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ nohup Xvfb :99 -screen 0 1920x1080x16 \ - & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 0.1 ; done \ + & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \ ; } \ - ; echo "Checking whether /image is a directory or a QEMU disk." \ - ; case "$(file --brief /image)" in \ - QEMU*) export IMAGE_PATH=/image;; \ - directory*) export IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img;; \ - esac \ ; stat "${IMAGE_PATH}" \ ; echo "Large image is being copied between layers, please wait a minute..." \ ; ./enable-ssh.sh \ diff --git a/Dockerfile.naked b/Dockerfile.naked index 28290a4..f002781 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -106,6 +106,8 @@ ENV BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 ENV DISPLAY=:99 +ENV HEADLESS=false + ENV ENV=/env ENV IMAGE_PATH=/image @@ -113,7 +115,7 @@ ENV IMAGE_PATH=/image ENV NOPICKER=true CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ - ; [[ "${DISPLAY}" = ':99' ]] && { \ + ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ nohup Xvfb :99 -screen 0 1920x1080x16 \ & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \ ; } \ @@ -145,10 +147,4 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; case "$(file --brief /bootdisk)" in \ - QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ - ;; \ - directory* ) export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 \ - ;; \ - esac \ ; ./enable-ssh.sh && envsubst < ./Launch.sh | bash