/g' | grep "$LANG 64-bit" | grep -o -P '(?<= | ).*(?= |
)')
# Limit untrusted size for input validation
iso_download_link_html="$(echo "$iso_download_link_html" | head -c 4096)"
if ! [ "$iso_download_link_html" ]; then
# This should only happen if there's been some change to how this API works
echo " - Microsoft servers gave us an empty response to our request for an automated download."
failed=1
fi
if echo "$iso_download_link_html" | grep -q "We are unable to complete your request at this time."; then
if [ "${show_iso_url}" == 1 ] || [ "${test_iso_url}" == 1 ]; then
echo " - Failed to get URL: Microsoft blocked the automated download request based on your IP address."
exit 1
fi
echo " - Microsoft blocked the automated download request based on your IP address."
failed=1
fi
if [ ${failed} -eq 1 ]; then
echo " - Manually download the Windows ${windows_version} ISO using a web browser from: ${url}"
echo " - Save the downloaded ISO to: $(realpath "${VM_PATH}")"
echo " - Update the config file to reference the downloaded ISO: ./${VM_PATH}.conf"
echo " - Continuing with the VM creation process..."
return 1
fi
# Filter for 64-bit ISO download URL
# sed: HTML decode "&" character
# tr: Filter for only alphanumerics or punctuation
local iso_download_link="$(echo "$iso_download_link_html" | grep -o "https://software.download.prss.microsoft.com.*IsoX64" | cut -d '"' -f 1 | sed 's/&/\&/g' | tr -cd '[:alnum:][:punct:]' | head -c 512)"
if ! [ "$iso_download_link" ]; then
# This should only happen if there's been some change to the download endpoint web address
echo " - Microsoft servers gave us no download link to our request for an automated download. Please manually download this ISO in a web browser: $url"
return 1
fi
if [ "${show_iso_url}" == 1 ]; then
echo -e " Windows ${RELEASE} Download (valid for 24 hours):\n${iso_download_link}"
exit 0
elif [ "${test_iso_url}" == 1 ]; then
wget --spider "${iso_download_link}"
exit 0
fi
if [ "${LANG}" != "English International" ]; then
echo Downloading Windows ${RELEASE} in "${LANG}" from "$iso_download_link"
else
echo Downloading Windows ${RELEASE} from "$iso_download_link"
fi
# Download ISO
FILE_NAME="$(echo "$iso_download_link" | cut -d'?' -f1 | cut -d'/' -f5)"
web_get "$iso_download_link" "${VM_PATH}" "${FILE_NAME}"
# Only Windows 11 hashes can be found directly from Microsoft's page.
if [ "${windows_version}" == 11 ]; then
check_hash "${FILE_NAME}" "${HASH}"
fi
}
function get_windows() {
if [ "${RELEASE}" == "10-ltsc" ]; then
download_windows-server windows-10-enterprise ltsc
elif [ "${OS}" == "windows-server" ]; then
download_windows-server windows-server-${RELEASE}
else
download_windows "${RELEASE}"
fi
if [ "${download_iso}" == 1 ]; then
exit 0
fi
echo "Downloading VirtIO drivers..."
web_get "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" "${VM_PATH}"
rm -f "${VM_PATH}/unattended.iso"
case ${RELEASE} in
10|11)
echo "Making unattended.iso"
mkdir -p "${VM_PATH}/unattended" 2>/dev/null
web_get https://www.spice-space.org/download/windows/spice-webdavd/spice-webdavd-x64-latest.msi "${VM_PATH}/unattended"
web_get https://www.spice-space.org/download/windows/vdagent/vdagent-win-0.10.0/spice-vdagent-x64-0.10.0.msi "${VM_PATH}/unattended"
web_get https://www.spice-space.org/download/windows/usbdk/UsbDk_1.0.22_x64.msi "${VM_PATH}/unattended"
unattended_windows "${VM_PATH}/unattended/autounattend.xml"
mkisofs -quiet -l -o "${VM_PATH}/unattended.iso" "${VM_PATH}/unattended/"
;;
esac
if [ -n "${FILE_NAME}" ]; then
make_vm_config "${FILE_NAME}" "virtio-win.iso"
else
make_vm_config "windows-${RELEASE}.iso" "virtio-win.iso"
fi
}
open_url() {
local URL="${1}";
xdg-open "$URL" || sensible-browser "$URL" || x-www-browser "$URL" || gnome-open "$URL";
}
create_vm() {
# shellcheck disable=SC2206
local URL_HASH=(${1// / })
local URL="${URL_HASH[0]}"
local HASH="${URL_HASH[1]}"
local ISO="${URL##*/}"
#echo "${URL}"
#echo "${ISO}"
#echo "${HASH}"
web_get "${URL}" "${VM_PATH}"
if [ -n "${HASH}" ]; then
check_hash "${ISO}" "${HASH}"
fi
if [ ${OS} == "freedos" ] && [[ $ISO =~ ".zip" ]]; then
unzip ${VM_PATH}/${ISO} -d ${VM_PATH}
ISO=$(find "${VM_PATH}" -type f -iname '*.iso')
fi
if [[ ${OS} == "batocera" ]] && [[ ${ISO} =~ ".gz" ]]; then
gzip -d "${VM_PATH}/${ISO}"
ISO="${ISO/.gz/}"
fi
# Could be other OS iso files compressed with bzip2 or gzip
# but for now we'll keep this to know cases
if [[ ${OS} == "dragonflybsd" ]] && [[ ${ISO} =~ ".bz2" ]]; then
bzip2 -d "${VM_PATH}/${ISO}"
ISO="${ISO/.bz2/}"
fi
if [ ${OS} == "reactos" ] && [[ $ISO =~ ".zip" ]]; then
unzip ${VM_PATH}/${ISO} -d ${VM_PATH}
ISO=$(find "${VM_PATH}" -type f \( -iname '*.iso' ! -iname '*.zip' \))
fi
make_vm_config "${ISO}"
}
trap cleanup EXIT
if ((BASH_VERSINFO[0] < 4)); then
echo "Sorry, you need bash 4.0 or newer to run this script."
exit 1
fi
LANGS=()
os_error() {
echo "ERROR! You must specify an operating system."
echo "- Supported Operating Systems:"
os_support | fold -s -w $(tput cols)
echo -e "\nTo see all possible arguments, use:\n quickget -h or quickget --help"
exit 1
}
os_supported() {
if [[ ! " $(os_support) " =~ " ${OS} " ]]; then
echo -e "ERROR! ${OS} is not a supported OS.\n"
os_support | fold -s -w $(tput cols)
exit 1
fi
}
function help_message() {
printf ' _ _
__ _ _ _ _ ___║ ║ ____ _ ___║ ║_
/ _` ║ ║ ║ ║ ║/ __║ ║/ / _` ║/ _ \ __║
( (_║ ║ ║_║ ║ ║ (__║ < (_║ ║ __/ ║_ MIT
\__, ║\__,_║_║\___║_║\ \__, ║\___║\__║ license
║_║ version: %s ║___/
QEMU %s --------------------------------------------------
> Quickly create and run optimised Windows, <
> macOS and Linux desktop virtual machines. <
homepage - Not Yet
repository - https://github.com/quickemu-project/quickemu
official GUI - https://github.com/quickemu-project/quickgui
by Wimpy https://github.com/flexiondotorg and contributors
Discord - https://discord.gg/wimpy-s-world-712850672223125565
--------------------------------------------------------------
Basic Usage:
quickget