2021-09-27 23:09:46 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function os_support() {
|
|
|
|
echo kubuntu \
|
|
|
|
lubuntu \
|
|
|
|
macos \
|
|
|
|
ubuntu \
|
2021-09-28 01:14:30 +00:00
|
|
|
ubuntu-budgie \
|
2021-09-27 23:09:46 +00:00
|
|
|
ubuntu-kylin \
|
|
|
|
ubuntu-mate \
|
|
|
|
ubuntu-studio \
|
2021-09-28 04:03:16 +00:00
|
|
|
windows \
|
2021-09-27 23:09:46 +00:00
|
|
|
xubuntu
|
|
|
|
}
|
|
|
|
|
|
|
|
function releases_macos() {
|
2021-09-28 14:25:38 +00:00
|
|
|
echo high-sierra \
|
|
|
|
mojave \
|
2021-09-27 23:09:46 +00:00
|
|
|
catalina \
|
|
|
|
big-sur
|
|
|
|
}
|
|
|
|
|
|
|
|
function releases_ubuntu() {
|
|
|
|
echo bionic \
|
|
|
|
focal \
|
|
|
|
hirsute \
|
|
|
|
devel
|
|
|
|
}
|
|
|
|
|
2021-09-28 04:03:16 +00:00
|
|
|
function languages_windows() {
|
|
|
|
echo Arabic \
|
|
|
|
Brazilian Portuguese \
|
|
|
|
Bulgarian \
|
|
|
|
Chinese \(Simplified\) \
|
|
|
|
Chinese \(Traditional\) \
|
|
|
|
Croatian \
|
|
|
|
Czech \
|
|
|
|
Danish \
|
|
|
|
Dutch \
|
|
|
|
English \
|
|
|
|
English International \
|
|
|
|
Estonian \
|
|
|
|
Finnish \
|
|
|
|
French \
|
|
|
|
French Canadian \
|
|
|
|
German \
|
|
|
|
Greek \
|
|
|
|
Hebrew \
|
|
|
|
Hungarian \
|
|
|
|
Italian \
|
|
|
|
Japanese \
|
|
|
|
Korean \
|
|
|
|
Latvian \
|
|
|
|
Lithuanian \
|
|
|
|
Norwegian \
|
|
|
|
Polish \
|
|
|
|
Portuguese \
|
|
|
|
Romanian \
|
|
|
|
Russian \
|
|
|
|
Serbian Latin \
|
|
|
|
Slovak \
|
|
|
|
Slovenian \
|
|
|
|
Spanish \
|
|
|
|
Spanish \(Mexico\) \
|
|
|
|
Swedish \
|
|
|
|
Thai \
|
|
|
|
Turkish \
|
|
|
|
Ukrainian
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function releases_windows() {
|
2021-10-05 22:51:57 +00:00
|
|
|
echo 8 \
|
|
|
|
10 \
|
|
|
|
11
|
2021-09-28 04:03:16 +00:00
|
|
|
}
|
|
|
|
|
2021-09-27 23:09:46 +00:00
|
|
|
function web_get() {
|
|
|
|
local DIR="${2}"
|
|
|
|
local FILE=""
|
|
|
|
local URL="${1}"
|
2021-09-28 04:03:16 +00:00
|
|
|
if [ -n "${3}" ]; then
|
|
|
|
FILE="${3}"
|
|
|
|
else
|
|
|
|
FILE="${URL##*/}"
|
|
|
|
fi
|
|
|
|
|
2021-09-27 23:09:46 +00:00
|
|
|
mkdir -p "${DIR}" 2>/dev/null
|
|
|
|
if ! wget --quiet --continue --show-progress --progress=bar:force:noscroll "${URL}" -O "${DIR}/${FILE}"; then
|
2021-09-28 04:03:16 +00:00
|
|
|
echo "ERROR! Failed to download ${URL}. Try running 'quickget' again."
|
2021-09-27 23:09:46 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function zsync_get() {
|
|
|
|
local DIR="${2}"
|
|
|
|
local FILE=""
|
2021-09-28 01:13:08 +00:00
|
|
|
local OUT=""
|
2021-09-27 23:09:46 +00:00
|
|
|
local URL="${1}"
|
|
|
|
FILE="${URL##*/}"
|
2021-09-28 01:13:08 +00:00
|
|
|
if [ -n "${3}" ]; then
|
|
|
|
OUT="${3}"
|
|
|
|
else
|
|
|
|
OUT="${FILE}"
|
|
|
|
fi
|
|
|
|
|
2021-09-27 23:09:46 +00:00
|
|
|
mkdir -p "${DIR}" 2>/dev/null
|
2021-09-28 01:13:08 +00:00
|
|
|
if ! zsync "${URL}.zsync" -i "${DIR}/${OUT}" -o "${DIR}/${OUT}"; then
|
2021-09-27 23:09:46 +00:00
|
|
|
echo "ERROR! Failed to download ${URL}.zsync"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e "${DIR}/${FILE}.zs-old" ]; then
|
|
|
|
rm -v "${DIR}/${FILE}.zs-old"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function make_vm_dir() {
|
|
|
|
if ! mkdir -p "${VM_PATH}" 2>/dev/null; then
|
|
|
|
echo "ERROR! Unable to create directory ${VM_PATH}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function make_vm_config() {
|
|
|
|
local IMAGE_FILE=""
|
2021-09-28 14:32:12 +00:00
|
|
|
local ISO_FILE=""
|
2021-09-27 23:09:46 +00:00
|
|
|
local IMAGE_TYPE=""
|
|
|
|
local GUEST=""
|
|
|
|
IMAGE_FILE="${1}"
|
2021-09-28 14:32:12 +00:00
|
|
|
ISO_FILE="${2}"
|
2021-09-27 23:09:46 +00:00
|
|
|
if [[ "${OS}" == *"ubuntu"* ]]; then
|
|
|
|
GUEST="linux"
|
|
|
|
IMAGE_TYPE="iso"
|
|
|
|
elif [ "${OS}" == "macos" ]; then
|
|
|
|
GUEST="macos"
|
|
|
|
IMAGE_TYPE="img"
|
2021-09-28 04:03:16 +00:00
|
|
|
elif [ "${OS}" == "windows" ]; then
|
|
|
|
GUEST="windows"
|
|
|
|
IMAGE_TYPE="iso"
|
2021-09-27 23:09:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -e "${OS}-${RELEASE}.conf" ]; then
|
|
|
|
echo "Making VM configuration for ${OS}-${RELEASE}..."
|
|
|
|
cat << EOF > "${OS}-${RELEASE}.conf"
|
|
|
|
guest_os="${GUEST}"
|
|
|
|
disk_img="${VM_PATH}/disk.qcow2"
|
2021-09-28 04:03:16 +00:00
|
|
|
${IMAGE_TYPE}="${VM_PATH}/${IMAGE_FILE}"
|
2021-09-27 23:09:46 +00:00
|
|
|
EOF
|
2021-09-28 14:32:12 +00:00
|
|
|
if [ -n "${ISO_FILE}" ]; then
|
|
|
|
echo "fixed_iso=\"${VM_PATH}/${ISO_FILE}\"" >> "${OS}-${RELEASE}.conf"
|
2021-09-28 04:03:16 +00:00
|
|
|
fi
|
2021-09-28 14:37:36 +00:00
|
|
|
|
2021-10-04 16:34:31 +00:00
|
|
|
if [ "${OS}" == "macos" ]; then
|
|
|
|
echo "macos_release=\"${RELEASE}\"" >> "${OS}-${RELEASE}.conf"
|
|
|
|
fi
|
2021-10-06 10:01:33 +00:00
|
|
|
|
|
|
|
# Enable TPM for Windows 11
|
|
|
|
if [ "${OS}" == "windows" ] && [ ${RELEASE} -ge 11 ]; then
|
|
|
|
echo "tpm=\"on\"" >> "${OS}-${RELEASE}.conf"
|
|
|
|
fi
|
2021-09-27 23:09:46 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function start_vm_info() {
|
|
|
|
echo
|
|
|
|
echo "To start your ${OS} ${RELEASE} virtual machine run:"
|
|
|
|
echo " quickemu --vm ${OS}-${RELEASE}.conf"
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_macos() {
|
|
|
|
local CWD=""
|
|
|
|
local MACRECOVERY=""
|
|
|
|
|
|
|
|
case ${RELEASE} in
|
|
|
|
high-sierra)
|
|
|
|
BOARD_ID="Mac-7BA5B2D9E42DDD94"
|
|
|
|
MLB="00000000000J80300";;
|
2021-09-28 14:26:10 +00:00
|
|
|
mojave)
|
2021-09-27 23:09:46 +00:00
|
|
|
BOARD_ID="Mac-7BA5B2DFE22DDD8C"
|
|
|
|
MLB="00000000000KXPG00";;
|
|
|
|
catalina)
|
|
|
|
BOARD_ID="Mac-CFF7D910A743CAAF"
|
|
|
|
MLB="00000000000PHCD00";;
|
|
|
|
big-sur)
|
|
|
|
BOARD_ID="Mac-E43C1C25D4880AD6"
|
|
|
|
MLB="00000000000000000";;
|
|
|
|
*) echo "ERROR! Unknown release: ${RELEASE}"
|
|
|
|
releases_macos
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Use a bundled macrecovery if possible
|
|
|
|
CWD="$(dirname ${0})"
|
2021-10-05 16:11:49 +00:00
|
|
|
if [ -x "${CWD}/macrecovery" ]; then
|
|
|
|
MACRECOVERY="${CWD}/macrecovery"
|
2021-09-27 23:09:46 +00:00
|
|
|
elif [ -x /usr/bin/macrecovery ]; then
|
|
|
|
MACRECOVERY="/usr/bin/macrecovery"
|
|
|
|
else
|
|
|
|
web_get "https://raw.githubusercontent.com/acidanthera/OpenCorePkg/master/Utilities/macrecovery/macrecovery.py" "${HOME}/.quickemu"
|
|
|
|
MACRECOVERY="python3 ${HOME}/.quickemu/macrecovery.py"
|
|
|
|
sed -i 's/\<env python\>/env python3/g' "${MACRECOVERY}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${MACRECOVERY}" ]; then
|
|
|
|
echo "ERROR! Can not find a usable macrecovery.py."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
make_vm_dir
|
|
|
|
|
2021-09-30 17:59:00 +00:00
|
|
|
# Get firmware
|
|
|
|
web_get "https://github.com/kholia/OSX-KVM/raw/master/OpenCore-Catalina/OpenCore.qcow2" "${VM_PATH}"
|
|
|
|
web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_CODE.fd" "${VM_PATH}"
|
|
|
|
if [ ! -e "${VM_PATH}/OVMF_VARS-1024x768.fd" ]; then
|
|
|
|
web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_VARS-1024x768.fd" "${VM_PATH}"
|
|
|
|
fi
|
|
|
|
|
2021-09-27 23:09:46 +00:00
|
|
|
if [ ! -e "${VM_PATH}/RecoveryImage.chunklist" ]; then
|
|
|
|
echo "Downloading ${RELEASE}..."
|
|
|
|
${MACRECOVERY} \
|
|
|
|
--board-id "${BOARD_ID}" \
|
|
|
|
--mlb "${MLB}" \
|
|
|
|
--basename RecoveryImage \
|
|
|
|
--outdir "${VM_PATH}" \
|
|
|
|
download
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e "${VM_PATH}/RecoveryImage.dmg" ] && [ ! -e "${VM_PATH}/RecoveryImage.img" ]; then
|
|
|
|
echo "Converting RecoveryImage..."
|
|
|
|
qemu-img convert "${VM_PATH}/RecoveryImage.dmg" -O raw "${VM_PATH}/RecoveryImage.img"
|
|
|
|
fi
|
|
|
|
|
|
|
|
make_vm_config RecoveryImage.img
|
|
|
|
start_vm_info
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_ubuntu() {
|
|
|
|
local DEVEL="daily-live"
|
|
|
|
local ISO=""
|
|
|
|
local PROJECT=""
|
|
|
|
local RELEASES=""
|
|
|
|
local URL=""
|
|
|
|
|
|
|
|
case ${OS} in
|
|
|
|
kubuntu|lubuntu|ubuntu|ubuntu-budgie|ubuntu-mate|xubuntu)
|
|
|
|
PROJECT="${OS}";;
|
|
|
|
ubuntu-kylin)
|
|
|
|
PROJECT="ubuntukylin";;
|
|
|
|
ubuntu-studio)
|
|
|
|
PROJECT="ubuntustudio"
|
|
|
|
DEVEL="dvd";;
|
|
|
|
*)
|
|
|
|
echo "ERROR! ${OS} is not a recognised Ubuntu flavour."
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ "${RELEASE}" == "devel" ]; then
|
|
|
|
URL="http://cdimage.ubuntu.com/${PROJECT}/${DEVEL}/current"
|
|
|
|
elif [ "${PROJECT}" == "ubuntu" ]; then
|
|
|
|
URL="http://releases.ubuntu.com/${RELEASE}"
|
|
|
|
else
|
|
|
|
URL="http://cdimage.ubuntu.com/${PROJECT}/releases/${RELEASE}/release"
|
|
|
|
fi
|
|
|
|
|
|
|
|
RELEASES=$(releases_ubuntu)
|
|
|
|
if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then
|
|
|
|
echo "ERROR! ${RELEASE} is not a supported release."
|
|
|
|
releases_ubuntu
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
make_vm_dir
|
|
|
|
|
|
|
|
echo "Downloading SHA256SUMS..."
|
|
|
|
web_get "${URL}/SHA256SUMS" "${VM_PATH}"
|
|
|
|
|
|
|
|
ISO=$(grep 'desktop\|dvd' "${VM_PATH}/SHA256SUMS" | grep amd64 | cut -d' ' -f2 | sed 's|*||g')
|
|
|
|
|
|
|
|
echo "Downloading "${URL}/${ISO}"..."
|
|
|
|
if [ "${RELEASE}" == "devel" ]; then
|
2021-09-28 01:13:08 +00:00
|
|
|
zsync_get "${URL}/${ISO}" "${VM_PATH}" "${OS}-${RELEASE}.iso"
|
|
|
|
make_vm_config "${OS}-${RELEASE}.iso"
|
2021-09-27 23:09:46 +00:00
|
|
|
else
|
|
|
|
web_get "${URL}/${ISO}" "${VM_PATH}"
|
|
|
|
echo "Checking SHA256SUMS..."
|
|
|
|
cd "${VM_PATH}"
|
|
|
|
if ! sha256sum --check SHA256SUMS --ignore-missing --status; then
|
|
|
|
echo "ERROR! ${ISO} doesn't match ${VM_PATH}/SHA256SUMS. Try running 'quickget' again."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "All good."
|
|
|
|
fi
|
|
|
|
cd ..
|
2021-09-28 01:13:08 +00:00
|
|
|
make_vm_config "${ISO}"
|
2021-09-27 23:09:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
start_vm_info
|
|
|
|
}
|
|
|
|
|
2021-09-28 04:03:16 +00:00
|
|
|
# Adapted from https://gist.github.com/hongkongkiwi/15a5bf16437315df256c118c163607cb
|
|
|
|
function get_windows() {
|
2021-10-05 19:08:13 +00:00
|
|
|
case ${RELEASE} in
|
2021-10-05 22:49:03 +00:00
|
|
|
8|10|11) true;;
|
2021-10-05 19:08:13 +00:00
|
|
|
*) echo "ERROR! Windows ${RELEASE} is not supported."
|
|
|
|
releases_windows
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2021-09-28 04:03:16 +00:00
|
|
|
|
|
|
|
local ARCH="x64"
|
|
|
|
local LANG_CODE="en"
|
|
|
|
local LATEST_WINDOWS_VERSION=""
|
|
|
|
local WINDOWS_NAME=""
|
|
|
|
local VERSION_ID=""
|
|
|
|
local EDITION_ID=""
|
|
|
|
local LANGUAGE_ID=""
|
|
|
|
local FILE_NAME=""
|
|
|
|
local ARCH_ID=""
|
|
|
|
local DOWNLOAD_INFO=""
|
|
|
|
local DOWNLOAD_ID=""
|
|
|
|
local DOWNLOAD_URL=""
|
|
|
|
|
|
|
|
echo "Getting Windows ${RELEASE} URL..."
|
2021-10-05 19:08:13 +00:00
|
|
|
WINDOWS_VERSIONS=$(wget -q -O- "https://tb.rg-adguard.net/php/get_version.php?type_id=1" | jq '.versions | sort_by(-(.version_id | tonumber))')
|
2021-10-05 22:49:03 +00:00
|
|
|
LATEST_WINDOWS_VERSION=$(echo "${WINDOWS_VERSIONS}" | jq -c 'map(select(.name | contains("Windows '${RELEASE}'")))[0]')
|
2021-10-05 19:08:13 +00:00
|
|
|
|
2021-09-28 04:03:16 +00:00
|
|
|
WINDOWS_NAME=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .name)
|
|
|
|
VERSION_ID=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .version_id)
|
2021-10-05 19:08:13 +00:00
|
|
|
|
|
|
|
case ${RELEASE} in
|
2021-10-05 22:49:03 +00:00
|
|
|
8) EDITION_ID=$(wget -q -O- "https://tb.rg-adguard.net/php/get_edition.php?version_id=${VERSION_ID}&lang=name_${LANG_CODE}" | jq -r '.editions[] | select(.name_'${LANG_CODE}'=="Windows 8.1 Pro + Core").edition_id');;
|
|
|
|
10|11) EDITION_ID=$(wget -q -O- "https://tb.rg-adguard.net/php/get_edition.php?version_id=${VERSION_ID}&lang=name_${LANG_CODE}" | jq -r '.editions[] | select(.name_'${LANG_CODE}'=="Windows '${RELEASE}'").edition_id');;
|
2021-10-05 19:08:13 +00:00
|
|
|
esac
|
|
|
|
|
2021-09-28 04:03:16 +00:00
|
|
|
LANGUAGE_ID=$(wget -q -O- "https://tb.rg-adguard.net/php/get_language.php?edition_id=${EDITION_ID}&lang=name_${LANG_CODE}" | jq -r '.languages[] | select(.name_'${LANG_CODE}'=="'"${LANG_NAME}"'").language_id')
|
|
|
|
ARCH_INFO=$(wget -q -O- "https://tb.rg-adguard.net/php/get_arch.php?language_id=${LANGUAGE_ID}")
|
|
|
|
FILE_NAME=$(echo "${ARCH_INFO}" | jq -r '.archs[] | select(.name | contains("'${ARCH}'")).name')
|
|
|
|
ARCH_ID=$(echo "${ARCH_INFO}" | jq -r '.archs[] | select(.name | contains("'${ARCH}'")).arch_id')
|
|
|
|
DOWNLOAD_INFO=$(wget -q -O- "https://tb.rg-adguard.net/dl.php?fileName=${ARCH_ID}&lang=en")
|
|
|
|
DOWNLOAD_ID=$(echo "${DOWNLOAD_INFO}" | grep -oP '(?<=https:\/\/tb\.rg-adguard\.net/dl\.php\?go=)[0-9a-z]+')
|
|
|
|
DOWNLOAD_URL="https://tb.rg-adguard.net/dl.php?go=${DOWNLOAD_ID}"
|
|
|
|
|
|
|
|
make_vm_dir
|
|
|
|
|
|
|
|
echo "Downloading ${WINDOWS_NAME}..."
|
|
|
|
web_get "${DOWNLOAD_URL}" "${VM_PATH}" "${FILE_NAME}"
|
|
|
|
|
|
|
|
echo "Downloading virtio-win.iso..."
|
|
|
|
web_get "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" "${VM_PATH}"
|
|
|
|
|
|
|
|
make_vm_config "${FILE_NAME}" "virtio-win.iso"
|
|
|
|
|
|
|
|
start_vm_info
|
|
|
|
}
|
|
|
|
|
2021-09-27 23:09:46 +00:00
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
OS="${1,,}"
|
|
|
|
else
|
|
|
|
echo "ERROR! You must specify an OS:"
|
|
|
|
os_support
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${2}" ]; then
|
|
|
|
RELEASE="${2,,}"
|
|
|
|
else
|
|
|
|
echo "ERROR! You must specify an OS release name."
|
|
|
|
if [ "${OS}" == "macos" ]; then
|
|
|
|
releases_macos
|
|
|
|
elif [[ "${OS}" == *"ubuntu"* ]]; then
|
|
|
|
releases_ubuntu
|
2021-10-05 22:51:57 +00:00
|
|
|
elif [ "${OS}" == "windows" ]; then
|
2021-09-28 04:03:16 +00:00
|
|
|
releases_windows
|
2021-09-27 23:09:46 +00:00
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-09-28 14:40:46 +00:00
|
|
|
VM_PATH="${OS}-${RELEASE}"
|
2021-09-27 23:09:46 +00:00
|
|
|
|
|
|
|
if [ "${OS}" == "macos" ]; then
|
|
|
|
get_macos
|
|
|
|
elif [[ "${OS}" == *"ubuntu"* ]]; then
|
|
|
|
get_ubuntu
|
2021-09-28 04:03:16 +00:00
|
|
|
elif [ "${OS}" == "windows" ]; then
|
|
|
|
if [ -n "${3}" ]; then
|
|
|
|
LANG_NAME="${3}"
|
|
|
|
LANG_NAMES=$(languages_windows)
|
|
|
|
if [[ "${LANG_NAMES}" != *"${LANG_NAME}"* ]]; then
|
|
|
|
echo "ERROR! ${LANG_NAME} is not a supported language:"
|
|
|
|
languages_windows
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
LANG_NAME="English International"
|
|
|
|
fi
|
|
|
|
get_windows "${LANG_NAME}"
|
2021-09-27 23:09:46 +00:00
|
|
|
else
|
|
|
|
echo "ERROR! You must specify an OS:"
|
|
|
|
os_support
|
|
|
|
exit 1
|
|
|
|
fi
|