mirror of
https://github.com/dockur/windows.git
synced 2025-10-29 12:15:50 +00:00
Update mido.sh
This commit is contained in:
parent
d2904b1ee9
commit
b03ecf4620
1 changed files with 9 additions and 9 deletions
18
src/mido.sh
18
src/mido.sh
|
|
@ -88,7 +88,7 @@ download_windows() {
|
||||||
esac
|
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
|
# 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)"
|
session_id=$(cat /proc/sys/kernel/random/uuid 2> /dev/null || uuidgen --random)
|
||||||
|
|
||||||
# Get product edition ID for latest release of given Windows version
|
# 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
|
# 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
|
||||||
|
|
@ -96,7 +96,7 @@ download_windows() {
|
||||||
# Also, keeping a "$WindowsVersions" array like Fido does would be way too much of a maintenance burden
|
# 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
|
# Remove "Accept" header that curl sends by default
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo " - Parsing download page: ${url}"
|
[[ "$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")" || {
|
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 $?
|
handle_curl_error $?
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
@ -124,13 +124,13 @@ download_windows() {
|
||||||
# SKU ID: This specifies the language of the ISO. We always use "English (United States)", however, the SKU for this changes with each Windows release
|
# SKU ID: This specifies the language of the ISO. We always use "English (United States)", however, the SKU for this changes with each Windows release
|
||||||
# We must make this request so our next one will be allowed
|
# We must make this request so our next one will be allowed
|
||||||
# --data "" is required otherwise no "Content-Length" header will be sent causing HTTP response "411 Length Required"
|
# --data "" is required otherwise no "Content-Length" header will be sent causing HTTP response "411 Length Required"
|
||||||
language_skuid_table_html="$(curl --silent --max-time 30 --request POST --user-agent "$user_agent" --data "" --header "Accept:" --max-filesize 10K --fail --proto =https --tlsv1.2 --http1.1 -- "https://www.microsoft.com/en-US/api/controls/contentinclude/html?pageId=a8f8f489-4c7f-463a-9ca6-5cff94d8d041&host=www.microsoft.com&segments=software-download,$url_segment_parameter&query=&action=getskuinformationbyproductedition&sessionId=$session_id&productEditionId=$product_edition_id&sdVersion=2")" || {
|
language_skuid_table_html=$(curl --silent --max-time 30 --request POST --user-agent "$user_agent" --data "" --header "Accept:" --max-filesize 10K --fail --proto =https --tlsv1.2 --http1.1 -- "https://www.microsoft.com/en-US/api/controls/contentinclude/html?pageId=a8f8f489-4c7f-463a-9ca6-5cff94d8d041&host=www.microsoft.com&segments=software-download,$url_segment_parameter&query=&action=getskuinformationbyproductedition&sessionId=$session_id&productEditionId=$product_edition_id&sdVersion=2") || {
|
||||||
handle_curl_error $?
|
handle_curl_error $?
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# tr: Filter for only alphanumerics or "-" to prevent HTTP parameter injection
|
# tr: Filter for only alphanumerics or "-" to prevent HTTP parameter injection
|
||||||
sku_id="$(echo "$language_skuid_table_html" | grep -m 1 ">${language}<" | sed 's/"//g' | cut -d ',' -f 1 | cut -d ':' -f 2 | tr -cd '[:alnum:]-' | head -c 16)"
|
sku_id=$(echo "$language_skuid_table_html" | grep -m 1 ">${language}<" | sed 's/"//g' | cut -d ',' -f 1 | cut -d ':' -f 2 | tr -cd '[:alnum:]-' | head -c 16)
|
||||||
|
|
||||||
if [ -z "$sku_id" ]; then
|
if [ -z "$sku_id" ]; then
|
||||||
language=$(getLanguage "$lang" "desc")
|
language=$(getLanguage "$lang" "desc")
|
||||||
|
|
@ -144,7 +144,7 @@ download_windows() {
|
||||||
# Get ISO download link
|
# Get ISO download link
|
||||||
# If any request is going to be blocked by Microsoft it's always this last one (the previous requests always seem to succeed)
|
# If any request is going to be blocked by Microsoft it's always this last one (the previous requests always seem to succeed)
|
||||||
# --referer: Required by Microsoft servers to allow request
|
# --referer: Required by Microsoft servers to allow request
|
||||||
iso_download_link_html="$(curl --silent --max-time 30 --request POST --user-agent "$user_agent" --data "" --referer "$url" --header "Accept:" --max-filesize 100K --fail --proto =https --tlsv1.2 --http1.1 -- "https://www.microsoft.com/en-US/api/controls/contentinclude/html?pageId=6e2a1789-ef16-4f27-a296-74ef7ef5d96b&host=www.microsoft.com&segments=software-download,$url_segment_parameter&query=&action=GetProductDownloadLinksBySku&sessionId=$session_id&skuId=$sku_id&language=English&sdVersion=2")"
|
iso_download_link_html=$(curl --silent --max-time 30 --request POST --user-agent "$user_agent" --data "" --referer "$url" --header "Accept:" --max-filesize 100K --fail --proto =https --tlsv1.2 --http1.1 -- "https://www.microsoft.com/en-US/api/controls/contentinclude/html?pageId=6e2a1789-ef16-4f27-a296-74ef7ef5d96b&host=www.microsoft.com&segments=software-download,$url_segment_parameter&query=&action=GetProductDownloadLinksBySku&sessionId=$session_id&skuId=$sku_id&language=English&sdVersion=2")
|
||||||
|
|
||||||
if ! [ "$iso_download_link_html" ]; then
|
if ! [ "$iso_download_link_html" ]; then
|
||||||
# This should only happen if there's been some change to how this API works
|
# This should only happen if there's been some change to how this API works
|
||||||
|
|
@ -160,7 +160,7 @@ download_windows() {
|
||||||
# Filter for 64-bit ISO download URL
|
# Filter for 64-bit ISO download URL
|
||||||
# sed: HTML decode "&" character
|
# sed: HTML decode "&" character
|
||||||
# tr: Filter for only alphanumerics or punctuation
|
# tr: Filter for only alphanumerics or punctuation
|
||||||
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:]')"
|
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:]')
|
||||||
|
|
||||||
if ! [ "$iso_download_link" ]; then
|
if ! [ "$iso_download_link" ]; then
|
||||||
# This should only happen if there's been some change to the download endpoint web address
|
# This should only happen if there's been some change to the download endpoint web address
|
||||||
|
|
@ -223,7 +223,7 @@ download_windows_eval() {
|
||||||
local url="https://www.microsoft.com/en-us/evalcenter/download-$windows_version"
|
local url="https://www.microsoft.com/en-us/evalcenter/download-$windows_version"
|
||||||
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${url}"
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${url}"
|
||||||
iso_download_page_html="$(curl --silent --max-time 30 --user-agent "$user_agent" --location --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url")" || {
|
iso_download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --location --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || {
|
||||||
handle_curl_error $?
|
handle_curl_error $?
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +242,7 @@ download_windows_eval() {
|
||||||
filter="https://go.microsoft.com/fwlink/p/?LinkID=[0-9]\+&clcid=0x[0-9a-z]\+&culture=${culture,,}&country=${country^^}"
|
filter="https://go.microsoft.com/fwlink/p/?LinkID=[0-9]\+&clcid=0x[0-9a-z]\+&culture=${culture,,}&country=${country^^}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
iso_download_links="$(echo "$iso_download_page_html" | grep -io "$filter")" || {
|
iso_download_links=$(echo "$iso_download_page_html" | grep -io "$filter") || {
|
||||||
# This should only happen if there's been some change to the download endpoint web address
|
# This should only happen if there's been some change to the download endpoint web address
|
||||||
if [[ "${lang,,}" == "en" ]] || [[ "${lang,,}" == "en-"* ]]; then
|
if [[ "${lang,,}" == "en" ]] || [[ "${lang,,}" == "en-"* ]]; then
|
||||||
error "Windows server download page gave us no download link!"
|
error "Windows server download page gave us no download link!"
|
||||||
|
|
@ -274,7 +274,7 @@ download_windows_eval() {
|
||||||
# Follow redirect so proceeding log message is useful
|
# Follow redirect so proceeding log message is useful
|
||||||
# This is a request we make this Fido doesn't
|
# This is a request we make this Fido doesn't
|
||||||
# We don't need to set "--max-filesize" here because this is a HEAD request and the output is to /dev/null anyway
|
# We don't need to set "--max-filesize" here because this is a HEAD request and the output is to /dev/null anyway
|
||||||
iso_download_link="$(curl --silent --max-time 30 --user-agent "$user_agent" --location --output /dev/null --silent --write-out "%{url_effective}" --head --fail --proto =https --tlsv1.2 --http1.1 -- "$iso_download_link")" || {
|
iso_download_link=$(curl --silent --max-time 30 --user-agent "$user_agent" --location --output /dev/null --silent --write-out "%{url_effective}" --head --fail --proto =https --tlsv1.2 --http1.1 -- "$iso_download_link") || {
|
||||||
# This should only happen if the Microsoft servers are down
|
# This should only happen if the Microsoft servers are down
|
||||||
handle_curl_error $?
|
handle_curl_error $?
|
||||||
return $?
|
return $?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue