quickemu/quickget

893 lines
26 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
function list_all() {
local DISPLAY_NAME
local FUNC
local LANG
local OS
local RELEASE
echo "Display Name,OS,Release,Language"
for OS in $(os_support); do
if [[ "${OS}" == *"ubuntu"* ]]; then
FUNC="ubuntu"
else
FUNC="${OS}"
fi
case ${OS} in
freebsd) DISPLAY_NAME="FreeBSD";;
linuxmint) DISPLAY_NAME="Linux Mint";;
macos) DISPLAY_NAME="macOS";;
opensuse) DISPLAY_NAME="OpenSUSE";;
popos) DISPLAY_NAME="Pop!_OS";;
ubuntu-budgie) DISPLAY_NAME="Ubuntu Budgie";;
ubuntu-kylin) DISPLAY_NAME="Ubuntu Kylin";;
ubuntu-mate) DISPLAY_NAME="Ubuntu MATE";;
ubuntu-studio) DISPLAY_NAME="Ubuntu Studio";;
*) DISPLAY_NAME="${OS^}";;
esac
for RELEASE in $("releases_${FUNC}"); do
if [ "${OS}" == "windows" ]; then
for LANG in "${LANGS[@]}"; do
echo "${DISPLAY_NAME},${OS},${RELEASE},${LANG}",
done
else
echo "${DISPLAY_NAME},${OS},${RELEASE},,"
fi
done
done
exit 0
}
function os_support() {
echo fedora \
freebsd \
kubuntu \
linuxmint \
lubuntu \
macos \
2021-10-16 20:27:45 +02:00
opensuse \
popos \
ubuntu \
2021-09-28 03:14:30 +02:00
ubuntu-budgie \
ubuntu-kylin \
ubuntu-mate \
ubuntu-studio \
2021-09-28 06:03:16 +02:00
windows \
xubuntu
}
function releases_freebsd(){
2021-10-07 17:36:38 +02:00
echo 12_2 \
13_0
}
2021-10-13 21:12:33 +02:00
function releases_fedora(){
echo 33 \
34 \
35_beta
}
function releases_linuxmint(){
echo cinnamon-20_2 \
mate-20_2 \
xfce-20-2
}
2021-10-16 20:27:45 +02:00
function releases_opensuse(){
echo 15_0 \
15_1 \
15_2 \
15_3 \
microos \
tumbleweed
2021-10-16 20:27:45 +02:00
}
function releases_macos() {
2021-09-28 16:25:38 +02:00
echo high-sierra \
mojave \
catalina \
big-sur
}
function releases_popos() {
echo 21_04
}
function releases_ubuntu() {
echo bionic \
focal \
hirsute \
2021-10-15 02:20:50 +02:00
impish \
devel
}
2021-09-28 06:03:16 +02:00
function languages_windows() {
LANGS=(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)
2021-09-28 06:03:16 +02:00
}
function releases_windows() {
2021-10-06 00:51:57 +02:00
echo 8 \
10 \
11
2021-09-28 06:03:16 +02:00
}
function unattended_windows() {
cat << 'EOF' > "${1}"
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
For documentation on components:
http://technet.microsoft.com/en-us/library/ff699038.aspx
-->
<settings pass="generalize">
<!--
The PersistAllDeviceInstalls setting indicates whether all plug and
play devices on the destination computer remain installed during the
generalize configuration pass.
-->
<component name="Microsoft-Windows-PnPSysprep"
processorArchitecture="amd64"
publicKeyToken="31bf3856ad364e35"
language="neutral"
versionScope="nonSxS">
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
</component>
</settings>
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64"
publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<DiskConfiguration>
<Disk wcm:action="add">
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>EFI</Type>
<Size>100</Size>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>MSR</Type>
<Size>512</Size>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>3</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Order>1</Order>
<PartitionID>1</PartitionID>
<Label>System</Label>
<Format>FAT32</Format>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<Order>2</Order>
<PartitionID>3</PartitionID>
<Label>Windows</Label>
<Letter>C</Letter>
<Format>NTFS</Format>
</ModifyPartition>
</ModifyPartitions>
</Disk>
<WillShowUI>OnError</WillShowUI>
</DiskConfiguration>
<ImageInstall>
<OSImage>
<WillShowUI>OnError</WillShowUI>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>3</PartitionID>
</InstallTo>
</OSImage>
</ImageInstall>
<UserData>
<AcceptEula>true</AcceptEula>
<ProductKey>
<key>VK7JG-NPHTM-C97JM-9MPGT-3V66T</key>
<WillShowUI>Never</WillShowUI>
</ProductKey>
</UserData>
<DynamicUpdate>
<Enable>true</Enable>
<WillShowUI>Never</WillShowUI>
</DynamicUpdate>
</component>
<component name="Microsoft-Windows-PnpCustomizationsWinPE"
publicKeyToken="31bf3856ad364e35" language="neutral"
versionScope="nonSxS" processorArchitecture="amd64">
<!--
This makes the VirtIO drivers available to Windows, assuming that
the VirtIO driver disk
(https://github.com/virtio-win/virtio-win-pkg-scripts/blob/master/README.md)
is available as drive E:
-->
<DriverPaths>
<PathAndCredentials wcm:action="add" wcm:keyValue="1">
<Path>E:\qemufwcfg\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="2">
<Path>E:\vioinput\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="3">
<Path>E:\vioscsi\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="4">
<Path>E:\viostor\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="5">
<Path>E:\vioserial\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="6">
<Path>E:\qxldod\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="7">
<Path>E:\amd64\w10</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="8">
<Path>E:\viogpudo\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="9">
<Path>E:\viorng\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="10">
<Path>E:\NetKVM\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="11">
<Path>E:\viofs\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="12">
<Path>E:\Balloon\w10\amd64</Path>
</PathAndCredentials>
</DriverPaths>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64"
publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<ComputerName>*</ComputerName>
<OEMInformation>
<Manufacturer>Wimpys World</Manufacturer>
<Model>Quickemu</Model>
<SupportHours>24/7</SupportHours>
<SupportPhone></SupportPhone>
<SupportProvider>Wimpys World</SupportProvider>
<SupportURL>https://github.com/wimpysworld/quickemu/issues</SupportURL>
</OEMInformation>
<OEMName>Wimpys World</OEMName>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64"
publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<OOBE>
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
</OOBE>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>msiexec /i E:\guest-agent\qemu-ga-x86_64.msi /quiet /passive /qn</CommandLine>
<Description>Install Virtio Guest Agent</Description>
<Order>1</Order>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>msiexec /i F:\spice-webdavd-x64-latest.msi /quiet /passive /qn</CommandLine>
<Description>Install spice-webdavd file sharing agent</Description>
<Order>2</Order>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>msiexec /i F:\UsbDk_1.0.22_x64.msi /quiet /passive /qn</CommandLine>
<Description>Install usbdk USB sharing agent</Description>
<Order>3</Order>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>msiexec /i F:\spice-vdagent-x64-0.10.0.msi /quiet /passive /qn</CommandLine>
<Description>Install spice-vdagent SPICE agent</Description>
<Order>4</Order>
</SynchronousCommand>
</FirstLogonCommands>
</component>
</settings>
</unattend>
EOF
}
function web_get() {
local DIR="${2}"
local FILE=""
local URL="${1}"
2021-09-28 06:03:16 +02:00
if [ -n "${3}" ]; then
FILE="${3}"
else
FILE="${URL##*/}"
fi
mkdir -p "${DIR}" 2>/dev/null
if ! wget --quiet --continue --show-progress --progress=bar:force:noscroll "${URL}" -O "${DIR}/${FILE}"; then
2021-09-28 06:03:16 +02:00
echo "ERROR! Failed to download ${URL}. Try running 'quickget' again."
exit 1
fi
}
function zsync_get() {
local DIR="${2}"
local FILE=""
local OUT=""
local URL="${1}"
FILE="${URL##*/}"
if [ -n "${3}" ]; then
OUT="${3}"
else
OUT="${FILE}"
fi
mkdir -p "${DIR}" 2>/dev/null
if ! zsync "${URL}.zsync" -i "${DIR}/${OUT}" -o "${DIR}/${OUT}"; then
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=""
local ISO_FILE=""
local IMAGE_TYPE=""
local GUEST=""
IMAGE_FILE="${1}"
ISO_FILE="${2}"
if [[ "${OS}" == "freebsd" ]]; then
GUEST="freebsd"
IMAGE_TYPE="iso"
elif [[ "${OS}" == "fedora" ]]; then
GUEST="linux"
IMAGE_TYPE="iso"
elif [[ "${OS}" == "linuxmint" ]]; then
GUEST="linux"
IMAGE_TYPE="iso"
elif [[ "${OS}" == "opensuse" ]]; then
2021-10-16 20:27:45 +02:00
GUEST="linux"
IMAGE_TYPE="iso"
elif [[ "${OS}" == "popos" ]]; then
GUEST="linux"
IMAGE_TYPE="iso"
2021-10-13 21:12:33 +02:00
elif [[ "${OS}" == *"ubuntu"* ]]; then
GUEST="linux"
2021-10-15 02:45:05 +02:00
IMAGE_TYPE="iso"
elif [ "${OS}" == "macos" ]; then
GUEST="macos"
IMAGE_TYPE="img"
2021-09-28 06:03:16 +02:00
elif [ "${OS}" == "windows" ]; then
GUEST="windows"
IMAGE_TYPE="iso"
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 06:03:16 +02:00
${IMAGE_TYPE}="${VM_PATH}/${IMAGE_FILE}"
EOF
if [ -n "${ISO_FILE}" ]; then
echo "fixed_iso=\"${VM_PATH}/${ISO_FILE}\"" >> "${OS}-${RELEASE}.conf"
2021-09-28 06:03:16 +02:00
fi
if [ "${OS}" == "macos" ]; then
echo "macos_release=\"${RELEASE}\"" >> "${OS}-${RELEASE}.conf"
fi
2021-10-06 12:01:33 +02:00
# Enable TPM for Windows 11
if [ "${OS}" == "windows" ] && [ ${RELEASE} -ge 11 ]; then
echo "tpm=\"on\"" >> "${OS}-${RELEASE}.conf"
fi
fi
}
function start_vm_info() {
echo
echo "To start your ${OS} ${RELEASE} virtual machine run:"
echo " quickemu --vm ${OS}-${RELEASE}.conf"
echo
}
function get_freebsd() {
# For future releases, use dvd1 iso files.
local URL=""
local DL_BASE="https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES"
local VERSION=""
2021-10-07 17:36:38 +02:00
case ${RELEASE} in
2021-10-07 17:36:38 +02:00
12_2|13_0) VERSION=${RELEASE//_/.};;
*)
echo "ERROR! FreeBSD ${RELEASE} is not a supported release."
releases_freebsd
exit 1
2021-10-07 17:36:38 +02:00
;;
esac
URL="${DL_BASE}/${VERSION}/FreeBSD-${VERSION}-RELEASE-amd64-dvd1.iso"
ISO="FreeBSD-${VERSION}-RELEASE-amd64-dvd1.iso"
make_vm_dir
web_get ${URL} ${VM_PATH}
make_vm_config ${ISO}
start_vm_info
}
2021-10-13 21:12:33 +02:00
function get_fedora() {
# For future releases, use dvd1 iso files.
local URL=""
local VERSION=""
case ${RELEASE} in
33|34|35_beta) VERSION=${RELEASE};;
*)
echo "ERROR! Fedora ${RELEASE} is not a supported release."
releases_fedora
exit 1
;;
esac
FEDORA_VERSIONS=$(wget -q -O- "https://getfedora.org/releases.json" | jq '.[] | select((.variant=="Workstation" or .variant=="Spins") and .arch=="x86_64")')
if [[ $VERSION == *"beta"* ]]; then
VERSION_NUM=${VERSION%"_beta"}
2021-10-15 02:45:05 +02:00
FEDORA_RELEASE=$(echo ${FEDORA_VERSIONS} | jq -c '. | select(.version | contains("Beta"))' | jq '. | select(.variant=="Workstation")')
2021-10-13 21:12:33 +02:00
ISO="Fedora-Workstation-Live-x86_64-${VERSION_NUM}_Beta-1.2.iso"
else
FEDORA_RELEASE=$(echo ${FEDORA_VERSIONS} | jq '. | select(.variant=="Workstation" and .version=="'${VERSION}'")')
ISO="Fedora-Workstation-Live-x86_64-${VERSION}-1.2.iso"
fi
2021-10-15 02:45:05 +02:00
2021-10-13 21:12:33 +02:00
URL=$(echo ${FEDORA_RELEASE} | jq -r '.link')
SHA256SUM=$(echo ${FEDORA_RELEASE} | jq -r '.sha256')
make_vm_dir
2021-10-13 21:12:33 +02:00
web_get ${URL} ${VM_PATH}
echo "Checking SHA256SUMS..."
cd "${VM_PATH}"
if ! echo "${SHA256SUM} ${ISO}" | sha256sum --check --status; then
echo "ERROR! ${ISO} doesn't match ${SHA256SUM}. Try running 'quickget' again."
exit 1
else
echo "All good."
fi
cd ..
2021-10-13 21:12:33 +02:00
make_vm_config ${ISO}
start_vm_info
}
function get_linuxmint() {
local URL=""
local DL_BASE="https://mirrors.edge.kernel.org/linuxmint/stable"
local VERSION=""
case ${RELEASE} in
cinnamon-20_2|mate-20_2|xfce-20_2) VERSION=${RELEASE//_/.};;
*)
echo "ERROR! linuxmint ${RELEASE} is not a supported release."
releases_linuxmint
exit 1
;;
esac
re='(.*)-(.*)'
[[ ${VERSION} =~ ${re} ]];
local FLAVOR=${BASH_REMATCH[1]}
VERSION=${BASH_REMATCH[2]}
ISO="linuxmint-${VERSION}-${FLAVOR}-64bit.iso"
URL="${DL_BASE}/${VERSION}/${ISO}"
make_vm_dir
web_get ${URL} ${VM_PATH}
make_vm_config ${ISO}
start_vm_info
}
2021-10-16 20:27:45 +02:00
function get_opensuse() {
# For future releases, use dvd1 iso files.
local URL=""
local DL_BASE="https://download.opensuse.org/"
local VERSION=""
case ${RELEASE} in
2021-10-18 13:30:06 +02:00
15_0|15_1|15_2|15_3|tumbleweed|microos) VERSION=${RELEASE//_/.};;
2021-10-16 20:27:45 +02:00
*)
echo "ERROR! openSUSE ${RELEASE} is not a supported release."
releases_opensuse
exit 1
;;
esac
if [ "${VERSION}" == "tumbleweed" ]; then
ISO="openSUSE-Tumbleweed-DVD-x86_64-Current.iso"
URL="${DL_BASE}/tumbleweed/iso/${ISO}"
2021-10-18 13:30:06 +02:00
elif
[ "${VERSION}" == "microos" ]; then
ISO="openSUSE-MicroOS-DVD-x86_64-Current.iso"
URL="${DL_BASE}/tumbleweed/iso/${ISO}"
2021-10-16 20:27:45 +02:00
else
ISO="openSUSE-Leap-${VERSION}-DVD-x86_64.iso"
URL="${DL_BASE}/distribution/leap/${VERSION}/iso/${ISO}"
fi
make_vm_dir
web_get ${URL} ${VM_PATH}
make_vm_config ${ISO}
start_vm_info
}
function get_macos() {
local CWD=""
local MACRECOVERY=""
case ${RELEASE} in
high-sierra)
BOARD_ID="Mac-7BA5B2D9E42DDD94"
MLB="00000000000J80300";;
2021-09-28 16:26:10 +02:00
mojave)
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 18:11:49 +02:00
if [ -x "${CWD}/macrecovery" ]; then
MACRECOVERY="${CWD}/macrecovery"
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
# 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
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_popos() {
# For future releases, use dvd1 iso files.
local URL=""
local DL_BASE="https://pop-iso.sfo2.cdn.digitaloceanspaces.com"
local VERSION=""
case ${RELEASE} in
21_04) VERSION=${RELEASE//_/.};;
*)
echo "ERROR! Pop!_OS ${RELEASE} is not a supported release."
releases_popos
exit 1
;;
esac
ISO="pop-os_21.04_amd64_intel_9.iso"
URL="${DL_BASE}/21.04/amd64/intel/9/${ISO}"
make_vm_dir
web_get ${URL} ${VM_PATH}
make_vm_config ${ISO}
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
zsync_get "${URL}/${ISO}" "${VM_PATH}" "${OS}-${RELEASE}.iso"
make_vm_config "${OS}-${RELEASE}.iso"
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 ..
make_vm_config "${ISO}"
fi
start_vm_info
}
2021-09-28 06:03:16 +02:00
# Adapted from https://gist.github.com/hongkongkiwi/15a5bf16437315df256c118c163607cb
function get_windows() {
2021-10-05 21:08:13 +02:00
case ${RELEASE} in
8|10|11) true;;
2021-10-05 21:08:13 +02:00
*) echo "ERROR! Windows ${RELEASE} is not supported."
releases_windows
exit 1
;;
esac
2021-09-28 06:03:16 +02: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 21:08:13 +02: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))')
LATEST_WINDOWS_VERSION=$(echo "${WINDOWS_VERSIONS}" | jq -c 'map(select(.name | contains("Windows '${RELEASE}'")))[0]')
2021-10-05 21:08:13 +02:00
2021-09-28 06:03:16 +02:00
WINDOWS_NAME=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .name)
VERSION_ID=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .version_id)
2021-10-05 21:08:13 +02:00
case ${RELEASE} in
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 21:08:13 +02:00
esac
2021-09-28 06:03:16 +02: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_SHA1=$(echo "${DOWNLOAD_INFO}" | sed -e 's/<[^>]*>//g' | grep -o -P '(?<=SHA1: ).*(?= expire)' | sed 's/Link//')
2021-09-28 06:03:16 +02:00
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}"
2021-10-09 17:10:58 +02:00
# Windows 10 doesn't include a SHA1 sum
# Only check the integrity is SHA1 is available.
if [ -n "${DOWNLOAD_SHA1}" ]; then
echo "${DOWNLOAD_SHA1} ${FILE_NAME}" > "${VM_PATH}/SHA1SUMS"
echo "Checking SHA1SUMS..."
cd "${VM_PATH}"
if ! sha1sum --check SHA1SUMS --ignore-missing --status; then
echo "ERROR! ${ISO} doesn't match ${VM_PATH}/SHA1SUMS. Try running 'quickget' again."
exit 1
else
echo "All good."
fi
cd ..
2021-10-09 17:10:58 +02:00
fi
2021-09-28 06:03:16 +02:00
echo "Downloading virtio-win.iso..."
web_get "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" "${VM_PATH}"
if [ ! -e "${VM_PATH}/unattended.iso" ]; then
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
fi
2021-09-28 06:03:16 +02:00
make_vm_config "${FILE_NAME}" "virtio-win.iso"
start_vm_info
}
LANGS=()
languages_windows
if [ -n "${1}" ]; then
OS="${1,,}"
if [ "${OS}" == "list" ]; then
list_all
fi
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."
2021-10-07 17:36:10 +02:00
if [ "${OS}" == "freebsd" ]; then
releases_freebsd
2021-10-16 20:09:39 +02:00
elif [ "${OS}" == "fedora" ]; then
releases_fedora
elif [ "${OS}" == "linuxmint" ]; then
releases_linuxmint
2021-10-16 20:27:45 +02:00
elif [ "${OS}" == "opensuse" ]; then
releases_opensuse
2021-10-07 17:36:10 +02:00
elif [ "${OS}" == "macos" ]; then
releases_macos
elif [ "${OS}" == "popos" ]; then
releases_popos
elif [[ "${OS}" == *"ubuntu"* ]]; then
releases_ubuntu
2021-10-06 00:51:57 +02:00
elif [ "${OS}" == "windows" ]; then
2021-09-28 06:03:16 +02:00
releases_windows
fi
exit 1
fi
VM_PATH="${OS}-${RELEASE}"
if [ "${OS}" == "macos" ]; then
get_macos
elif [[ "${OS}" == "freebsd" ]]; then
get_freebsd
elif [[ "${OS}" == "fedora" ]]; then
2021-10-13 21:12:33 +02:00
get_fedora
elif [[ "${OS}" == "linuxmint" ]]; then
get_linuxmint
elif [[ "${OS}" == "opensuse" ]]; then
2021-10-16 20:27:45 +02:00
get_opensuse
elif [[ "${OS}" == "popos" ]]; then
get_popos
elif [[ "${OS}" == *"ubuntu"* ]]; then
get_ubuntu
2021-09-28 06:03:16 +02:00
elif [ "${OS}" == "windows" ]; then
if [ -n "${3}" ]; then
LANG_NAME="${3}"
if [[ ! ${LANGS[*]} =~ ${LANG_NAME} ]]; then
2021-09-28 06:03:16 +02:00
echo "ERROR! ${LANG_NAME} is not a supported language:"
for LANG in "${LANGS[@]}"; do
echo "${LANG}"
done
2021-09-28 06:03:16 +02:00
exit 1
fi
else
LANG_NAME="English International"
fi
get_windows "${LANG_NAME}"
else
echo "ERROR! You must specify an OS:"
os_support
exit 1
fi