From ded8a49d6232f828d0c09af95dff4938154c38ef Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 30 Sep 2024 23:30:13 +0200 Subject: [PATCH 01/14] Update define.sh --- src/define.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/define.sh b/src/define.sh index 5bc3223..fb47df8 100644 --- a/src/define.sh +++ b/src/define.sh @@ -488,7 +488,7 @@ getLink1() { [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0 size=4821989376 sum="e8f1431c4e6289b3997c20eadbb2576670300bb6e1cf8948b5d7af179010a962" - url="26100.1.240331-1435.ge_release_CLIENT_ENTERPRISES_OEM_A64FRE_en-us.iso" + url="X23-81950_26100.1742.240906-0331.ge_release_svc_refresh_CLIENT_ENTERPRISES_OEM_A64FRE_en-us.iso" ;; "win10arm64" | "win10arm64-enterprise" | "win10arm64-enterprise-eval" ) case "${culture,,}" in @@ -576,7 +576,7 @@ getLink2() { [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0 size=4821989376 sum="e8f1431c4e6289b3997c20eadbb2576670300bb6e1cf8948b5d7af179010a962" - url="11/26100.1.240331-1435.ge_release_CLIENT_ENTERPRISES_OEM_A64FRE_en-us.iso" + url="11/X23-81950_26100.1742.240906-0331.ge_release_svc_refresh_CLIENT_ENTERPRISES_OEM_A64FRE_en-us.iso" ;; "win10arm64" | "win10arm64-enterprise" | "win10arm64-enterprise-eval" ) size=4846794752 From a2338724b9a17dea9aa95c78035023673b146ad9 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 30 Sep 2024 23:38:30 +0200 Subject: [PATCH 02/14] fix: Update Windows 11 LTSC mirrors --- src/define.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/define.sh b/src/define.sh index fb47df8..1a22f0a 100644 --- a/src/define.sh +++ b/src/define.sh @@ -486,8 +486,8 @@ getLink1() { ;; "win11arm64-ltsc" | "win11arm64-enterprise-ltsc-eval" ) [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0 - size=4821989376 - sum="e8f1431c4e6289b3997c20eadbb2576670300bb6e1cf8948b5d7af179010a962" + size=5121449984 + sum="f8f068cdc90c894a55d8c8530db7c193234ba57bb11d33b71383839ac41246b4" url="X23-81950_26100.1742.240906-0331.ge_release_svc_refresh_CLIENT_ENTERPRISES_OEM_A64FRE_en-us.iso" ;; "win10arm64" | "win10arm64-enterprise" | "win10arm64-enterprise-eval" ) @@ -574,8 +574,8 @@ getLink2() { ;; "win11arm64-ltsc" | "win11arm64-enterprise-ltsc-eval" ) [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0 - size=4821989376 - sum="e8f1431c4e6289b3997c20eadbb2576670300bb6e1cf8948b5d7af179010a962" + size=5121449984 + sum="f8f068cdc90c894a55d8c8530db7c193234ba57bb11d33b71383839ac41246b4" url="11/X23-81950_26100.1742.240906-0331.ge_release_svc_refresh_CLIENT_ENTERPRISES_OEM_A64FRE_en-us.iso" ;; "win10arm64" | "win10arm64-enterprise" | "win10arm64-enterprise-eval" ) From 6a2df44f35bb4075d23b651cf31f3946e99f60ab Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 30 Sep 2024 23:42:11 +0200 Subject: [PATCH 03/14] docs: Add Windows 11 LTSC --- readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index e07072f..cacca47 100644 --- a/readme.md +++ b/readme.md @@ -89,13 +89,14 @@ kubectl apply -f kubernetes.yml | **Value** | **Version** | **Platform** | **Size** | |---|---|---|---| | `win11` | Windows 11 Pro | ARM64 | 4.9 GB | + | `ltsc11` | Windows 11 LTSC | ARM64 | 4.8 GB | | `win11e` | Windows 11 Enterprise | ARM64 | 4.8 GB | | `win10` | Windows 10 Pro | ARM64 | 3.5 GB | | `ltsc10` | Windows 10 LTSC | ARM64 | 4.1 GB | | `win10e` | Windows 10 Enterprise | ARM64 | 3.4 GB | > [!TIP] -> To install x86 and x64 versions of Windows, use [dockur/windows](https://github.com/dockur/windows/). +> To install x64 versions of Windows, use [dockur/windows](https://github.com/dockur/windows/). ### How do I select the Windows language? From 49e6e5a3f1c8ea1c08da91e6d3987243d4dfca8d Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 30 Sep 2024 23:50:08 +0200 Subject: [PATCH 04/14] feat: Add download mirror --- src/mido.sh | 357 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 357 insertions(+) diff --git a/src/mido.sh b/src/mido.sh index 449b972..19b1efa 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -1,6 +1,353 @@ #!/usr/bin/env bash set -Eeuo pipefail +handle_curl_error() { + + local error_code="$1" + + case "$error_code" in + 1) error "Unsupported protocol!" ;; + 2) error "Failed to initialize curl!" ;; + 3) error "The URL format is malformed!" ;; + 5) error "Failed to resolve address of proxy host!" ;; + 6) error "Failed to resolve Microsoft servers! Is there an Internet connection?" ;; + 7) error "Failed to contact Microsoft servers! Is there an Internet connection or is the server down?" ;; + 8) error "Microsoft servers returned a malformed HTTP response!" ;; + 16) error "A problem was detected in the HTTP2 framing layer!" ;; + 22) error "Microsoft servers returned a failing HTTP status code!" ;; + 23) error "Failed at writing Windows media to disk! Out of disk space or permission error?" ;; + 26) error "Failed to read Windows media from disk!" ;; + 27) error "Ran out of memory during download!" ;; + 28) error "Connection timed out to Microsoft server!" ;; + 35) error "SSL connection error from Microsoft server!" ;; + 36) error "Failed to continue earlier download!" ;; + 52) error "Received no data from the Microsoft server!" ;; + 63) error "Microsoft servers returned an unexpectedly large response!" ;; + # POSIX defines exit statuses 1-125 as usable by us + # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_02 + $((error_code <= 125))) + # Must be some other server or network error (possibly with this specific request/file) + # This is when accounting for all possible errors in the curl manual assuming a correctly formed curl command and an HTTP(S) request, using only the curl features we're using, and a sane build + error "Miscellaneous server or network error, reason: $error_code" + ;; + 126 | 127 ) error "Curl command not found!" ;; + # Exit statuses are undefined by POSIX beyond this point + *) + case "$(kill -l "$error_code")" in + # Signals defined to exist by POSIX: + # https://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html + INT) error "Curl was interrupted!" ;; + # There could be other signals but these are most common + SEGV | ABRT ) error "Curl crashed! Please report any core dumps to curl developers." ;; + *) error "Curl terminated due to fatal signal $error_code !" ;; + esac + esac + + return 1 +} + +get_agent() { + + local user_agent + + # Determine approximate latest Firefox release + browser_version="$((124 + ($(date +%s) - 1710892800) / 2419200))" + echo "Mozilla/5.0 (X11; Linux x86_64; rv:${browser_version}.0) Gecko/20100101 Firefox/${browser_version}.0" + + return 0 +} + +download_windows() { + + local id="$1" + local lang="$2" + local desc="$3" + local sku_id="" + local language="" + local session_id="" + local user_agent="" + local windows_version="" + local iso_download_link="" + local product_edition_id="" + local iso_download_link_html="" + local iso_download_page_html="" + local language_skuid_table_html="" + + case "${id,,}" in + "win11x64" ) windows_version="11" ;; + "win10x64" ) windows_version="10" ;; + "win81x64" ) windows_version="8" ;; + * ) error "Invalid VERSION specified, value \"$id\" is not recognized!" && return 1 ;; + esac + + user_agent=$(get_agent) + language=$(getLanguage "$lang" "name") + + local url="https://www.microsoft.com/en-us/software-download/windows$windows_version" + case "$windows_version" in + 8 | 10) url+="ISO";; + esac + + # uuidgen: For MacOS (installed by default) and other systems (e.g. with no /proc) that don't have a kernel interface for generating random UUIDs + session_id=$(cat /proc/sys/kernel/random/uuid 2> /dev/null || uuidgen --random) + + # Get product edition ID for latest release of given Windows version + # Product edition ID: This specifies both the Windows release (e.g. 22H2) and edition ("multi-edition" is default, either Home/Pro/Edu/etc., we select "Pro" in the answer files) in one number + # This is the *only* request we make that Fido doesn't. Fido manually maintains a list of all the Windows release/edition product edition IDs in its script (see: $WindowsVersions array). This is helpful for downloading older releases (e.g. Windows 10 1909, 21H1, etc.) but we always want to get the newest release which is why we get this value dynamically + # Also, keeping a "$WindowsVersions" array like Fido does would be way too much of a maintenance burden + # Remove "Accept" header that curl sends by default + [[ "$DEBUG" == [Yy1]* ]] && echo " - Parsing download page: ${url}" + iso_download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --header "Accept:" --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || { + handle_curl_error $? + return $? + } + + [[ "$DEBUG" == [Yy1]* ]] && echo -n "Getting Product edition ID: " + # tr: Filter for only numerics to prevent HTTP parameter injection + # head -c was recently added to POSIX: https://austingroupbugs.net/view.php?id=407 + product_edition_id=$(echo "$iso_download_page_html" | grep -Eo '