2024-05-16 19:39:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#!/usr/bin/env bash
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  -Eeuo pipefail 
						 
					
						
							
								
									
										
										
										
											2024-01-22 02:56:28 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:07:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								handle_curl_error( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:37:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  error_code = " $1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  case  " $error_code "  in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    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!"  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    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 "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! Failed exploitation attempt? Please report any core dumps to curl developers."  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        *)  error "Curl terminated due to a fatal signal!"  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  esac 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:37:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  return  1 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:07:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								download_windows( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:07:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 23:04:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  id = " $1 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:10:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  lang = " $2 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  sku_id = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:10:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  language = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 23:40:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  session_id = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:28:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  browser_version = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  windows_version = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 23:40:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  iso_download_link = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  product_edition_id = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  iso_download_link_html = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  iso_download_page_html = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  language_skuid_table_html = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  case  " ${ id ,, } "  in
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 02:04:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    " win11 ${ PLATFORM ,, } "  )  windows_version = "11"  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " win10 ${ PLATFORM ,, } "  )  windows_version = "10"  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " win81 ${ PLATFORM ,, } "  )  windows_version = "8"  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    * )  error " Invalid VERSION specified, value \" $id \" is not recognized! "  &&  return  1  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  language = $( getLanguage " $lang "  "name" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:10:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  url = " https://www.microsoft.com/en-us/software-download/windows $windows_version " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  case  " $windows_version "  in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    8  |  10)  url = " ${ url } ISO " ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:28:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # Determine approximate latest Firefox release 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  browser_version = " $(( 124  +  ( $( date +%s)  -  1710892800 )  /  2419200 )) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  user_agent = " Mozilla/5.0 (X11; Linux x86_64; rv: ${ browser_version } .0) Gecko/20100101 Firefox/ ${ browser_version } .0 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:03:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # 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 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 23:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  "  - Parsing download page:  ${ url } " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:44:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  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 " ) "  ||  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    handle_curl_error $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  -n "Getting Product edition ID: " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # 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 '<option value="[0-9]+">Windows'  |  cut -d '"'  -f 2  |  head -n 1  |  tr -cd '0-9'  |  head -c 16) " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 23:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  " $product_edition_id " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  " Permit Session ID:  $session_id " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # Permit Session ID 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # "org_id" is always the same value 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:44:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  curl --silent --max-time 30  --output /dev/null --user-agent " $user_agent "  --header "Accept:"  --max-filesize 100K --fail --proto = https --tlsv1.2 --http1.1 -- " https://vlscppe.microsoft.com/tags?org_id=y6jn8c31&session_id= $session_id "  ||  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # This should only happen if there's been some change to how this API works 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    handle_curl_error $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # Extract everything after the last slash 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  url_segment_parameter = " ${ url ##*/ } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  -n "Getting language SKU ID: " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # Get language -> skuID association table 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # 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 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # --data "" is required otherwise no "Content-Length" header will be sent causing HTTP response "411 Length Required" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:44:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  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 " ) "  ||  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    handle_curl_error $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # tr: Filter for only alphanumerics or "-" to prevent HTTP parameter injection 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:59:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  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) " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 11:29:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  [  -z " $sku_id "  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    language = $( getLanguage " $lang "  "desc" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:33:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    error " No download for the  $language  language available! " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 11:29:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  " $sku_id " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  "Getting ISO download link..." 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 11:29:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # 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) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # --referer: Required by Microsoft servers to allow request 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:44:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  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 " ) " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ! [  " $iso_download_link_html "  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # This should only happen if there's been some change to how this API works 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 23:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    error "Microsoft servers gave us an empty response to our request for an automated download." 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:07:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  echo  " $iso_download_link_html "  |  grep -q "We are unable to complete your request at this time." ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 23:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    error "Microsoft blocked the automated download request based on your IP address." 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # Filter for 64-bit ISO download URL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # sed: HTML decode "&" character 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # 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:]' ) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ! [  " $iso_download_link "  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # This should only happen if there's been some change to the download endpoint web address 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:51:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    error "Microsoft servers gave us no download link to our request for an automated download!" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  MIDO_URL = " $iso_download_link " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:07:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 22:25:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								download_windows_eval( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  id = " $1 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:10:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  lang = " $2 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  culture = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  language = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  windows_version = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  enterprise_type = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  case  " ${ id ,, } "  in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " win11 ${ PLATFORM ,, } -enterprise-eval "  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      windows_version = "windows-11-enterprise" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      enterprise_type = "enterprise"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    " win10 ${ PLATFORM ,, } -enterprise-eval "  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      windows_version = "windows-10-enterprise" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      enterprise_type = "enterprise"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    " win10 ${ PLATFORM ,, } -enterprise-ltsc-eval "  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      windows_version = "windows-10-enterprise" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      enterprise_type = "ltsc"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "win2022-eval"  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      windows_version = "windows-server-2022" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      enterprise_type = "server"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "win2019-eval"  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      windows_version = "windows-server-2019" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      enterprise_type = "server"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "win2016-eval"  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      windows_version = "windows-server-2016" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      enterprise_type = "server"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "win2012r2-eval"  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      windows_version = "windows-server-2012-r2" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      enterprise_type = "server"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    * ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 02:04:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      error " Invalid VERSION specified, value \" $id \" is not recognized! "  &&  return  1  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  esac 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:14:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  culture = $( getLanguage " $lang "  "culture" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:10:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  country = " ${ culture #*- } " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  iso_download_page_html = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  url = " https://www.microsoft.com/en-us/evalcenter/download- $windows_version " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  " Parsing download page:  ${ url } " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:44:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  iso_download_page_html = " $( curl --silent --max-time 30  --location --max-filesize 1M --fail --proto = https --tlsv1.2 --http1.1 -- " $url " ) "  ||  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    handle_curl_error $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ! [  " $iso_download_page_html "  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # This should only happen if there's been some change to where this download page is located 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:14:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    error "Windows server download page gave us an empty response" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  [ [  " $DEBUG "  = =  [ Yy1] * ] ]  &&  echo  "Getting download link.." 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  iso_download_links = " $( echo  " $iso_download_page_html "  |  grep -o " https://go.microsoft.com/fwlink/p/?LinkID=[0-9]\+&clcid=0x[0-9a-z]\+&culture= ${ culture ,, } &country= ${ country ^^ } " ) "  ||  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # This should only happen if there's been some change to the download endpoint web address 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  [ [  " ${ lang ,, } "  = =  "en"  ] ]  ||  [ [  " ${ lang ,, } "  = =  "en-" * ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      error "Windows server download page gave us no download link!" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      language = $( getLanguage " $lang "  "desc" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:33:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      error " No download for the  $language  language available! " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # Limit untrusted size for input validation 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  iso_download_links = " $( echo  " $iso_download_links "  |  head -c 1024) " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  case  " $enterprise_type "  in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Select x64 download link 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "enterprise" )  iso_download_link = $( echo  " $iso_download_links "  |  head -n 2  |  tail -n 1)  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Select x64 LTSC download link 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "ltsc" )  iso_download_link = $( echo  " $iso_download_links "  |  head -n 4  |  tail -n 1)  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    *)  iso_download_link = " $iso_download_links "  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # Follow redirect so proceeding log message is useful 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # 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 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:44:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  iso_download_link = " $( curl --silent --max-time 30  --location --output /dev/null --silent --write-out "%{url_effective}"  --head --fail --proto = https --tlsv1.2 --http1.1 -- " $iso_download_link " ) "  ||  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # This should only happen if the Microsoft servers are down 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    handle_curl_error $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  MIDO_URL = " $iso_download_link " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								getWindows( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 02:04:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  version = " $1 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  lang = " $2 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 01:32:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  desc = " $3 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  language
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:34:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:56:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  msg = " Requesting  $desc  from Microsoft server... " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:43:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  info " $msg "  &&  html " $msg " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:10:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 02:04:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  case  " ${ version ,, } "  in
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:37:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    " win81 ${ PLATFORM ,, } "  |  " win10 ${ PLATFORM ,, } "  |  " win11 ${ PLATFORM ,, } "  ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      download_windows " $version "  " $lang "  &&  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " win11 ${ PLATFORM ,, } -enterprise-eval "  ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      download_windows_eval " $version "  " $lang "  &&  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    " win10 ${ PLATFORM ,, } -enterprise-eval "  |  " win10 ${ PLATFORM ,, } -enterprise-ltsc-eval "  ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      download_windows_eval " $version "  " $lang "  &&  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "win2022-eval"  |  "win2019-eval"  |  "win2016-eval"  |  "win2012r2-eval"  ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      download_windows_eval " $version "  " $lang "  &&  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " win81 ${ PLATFORM ,, } -enterprise-eval "  ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      if  [ [  " ${ lang ,, } "  = =  "en"  ] ]  ||  [ [  " ${ lang ,, } "  = =  "en-" * ] ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        MIDO_URL = "https://download.microsoft.com/download/B/9/9/B999286E-0A47-406D-8B3D-5B5AD7373A4A/9600.17050.WINBLUE_REFRESH.140317-1640_X64FRE_ENTERPRISE_EVAL_EN-US-IR3_CENA_X64FREE_EN-US_DV9.ISO"  &&  return  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      fi 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      language = $( getLanguage " $lang "  "desc" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:33:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      error " No download for the  $language  language available! " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 21:47:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "win2008r2"  ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      if  [ [  " ${ lang ,, } "  = =  "en"  ] ]  ||  [ [  " ${ lang ,, } "  = =  "en-" * ] ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:25:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        MIDO_URL = "https://download.microsoft.com/download/4/1/D/41DEA7E0-B30D-4012-A1E3-F24DC03BA1BB/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso"  &&  return  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      fi 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      language = $( getLanguage " $lang "  "desc" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:33:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      error " No download for the  $language  language available! " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 02:04:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    * )  error " Invalid VERSION specified, value \" $version \" is not recognized! "  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:43:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  MIDO_URL = "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:36:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  return  1 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:07:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:12:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								getCatalog( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  id = " $1 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 02:14:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  ret = " $2 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:12:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  url = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  name = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  edition = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  case  " ${ id ,, } "  in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " win11 ${ PLATFORM ,, } "  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      edition = "Professional" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      name = "Windows 11 Pro" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      url = "https://go.microsoft.com/fwlink?linkid=2156292"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:12:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    " win10 ${ PLATFORM ,, } "  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      edition = "Professional" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      name = "Windows 10 Pro" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      url = "https://go.microsoft.com/fwlink/?LinkId=841361"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:12:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    " win11 ${ PLATFORM ,, } -enterprise "  |  " win11 ${ PLATFORM ,, } -enterprise-eval " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      edition = "Enterprise" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      name = "Windows 11 Enterprise" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      url = "https://go.microsoft.com/fwlink?linkid=2156292"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:12:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    " win10 ${ PLATFORM ,, } -enterprise "  |  " win10 ${ PLATFORM ,, } -enterprise-eval "  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      edition = "Enterprise" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      name = "Windows 10 Enterprise" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      url = "https://go.microsoft.com/fwlink/?LinkId=841361"  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 20:12:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  case  " ${ ret ,, } "  in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "url"  )  echo  " $url "  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "name"  )  echo  " $name "  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "edition"  )  echo  " $edition "  ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    *)  echo  "" ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:51:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								getESD( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  dir = " $1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  version = " $2 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  lang = " $3 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 01:32:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  desc = " $4 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  culture
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  language
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:51:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  editionName
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  winCatalog size
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  culture = $( getLanguage " $lang "  "culture" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 02:14:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  winCatalog = $( getCatalog " $version "  "url" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  editionName = $( getCatalog " $version "  "edition" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 02:04:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [  -z " $winCatalog "  ]  ||  [  -z " $editionName "  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:51:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    error " Invalid VERSION specified, value \" $version \" is not recognized! "  &&  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:56:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  msg = "Downloading product information from Microsoft server..." 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:51:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  info " $msg "  &&  html " $msg " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  rm -rf " $dir " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  mkdir -p " $dir " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  wFile = "catalog.cab" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  xFile = "products.xml" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  eFile = "esd_edition.xml" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  fFile = "products_filter.xml" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:45:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  {  wget " $winCatalog "  -O " $dir / $wFile "  -q --timeout= 30;  rc = $? ;  }  ||  :
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:28:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  ( (  rc  = =  4  ) )  &&  error " Failed to download  $winCatalog  , network failure! "  &&  return  1 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:51:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  ( (  rc !=  0  ) )  &&  error " Failed to download  $winCatalog  , reason:  $rc "  &&  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  cd  " $dir " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ! cabextract " $wFile "  > /dev/null;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cd  /run
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    error " Failed to extract  $wFile ! "  &&  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  cd  /run
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [  ! -s " $dir / $xFile "  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    error " Failed to find  $xFile  in  $wFile ! "  &&  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  edQuery = '//File[Architecture="' ${ PLATFORM } '"][Edition="' ${ editionName } '"]' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  echo  -e '<Catalog>'  > " $dir / $fFile " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  xmllint --nonet --xpath " ${ edQuery } "  " $dir / $xFile "  >> " $dir / $fFile "  2>/dev/null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  echo  -e '</Catalog>' >> " $dir / $fFile " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 12:55:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:40:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  xmllint --nonet --xpath '//File[LanguageCode="' ${ culture ,, } '"]'  " $dir / $fFile "  >" $dir / $eFile " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:51:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  size = $( stat -c%s " $dir / $eFile " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( ( size<20) ) ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 21:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    language = $( getLanguage " $lang "  "desc" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:33:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    error " the  $language  language is not supported by this download method! "  &&  return  1 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:51:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  tag = "FilePath" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ESD = $( xmllint --nonet --xpath " // $tag "  " $dir / $eFile "  |  sed -E -e " s/<[\/]? $tag >//g " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [  -z " $ESD "  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    error " Failed to find ESD URL in  $eFile ! "  &&  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  tag = "Sha1" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ESD_SUM = $( xmllint --nonet --xpath " // $tag "  " $dir / $eFile "  |  sed -E -e " s/<[\/]? $tag >//g " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  tag = "Size" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ESD_SIZE = $( xmllint --nonet --xpath " // $tag "  " $dir / $eFile "  |  sed -E -e " s/<[\/]? $tag >//g " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  rm -rf " $dir " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:50:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								verifyFile( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  iso = " $1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  size = " $2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  total = " $3 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  check = " $4 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [  -n " $size "  ]  &&  [ [  " $total "  !=  " $size "  ] ]  &&  [ [  " $size "  !=  "0"  ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    warn " The downloaded file has an unexpected size:  $total  bytes, while expected value was:  $size  bytes. Please report this at  $SUPPORT /issues " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  hash = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  algo = "SHA256" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  [  -z " $check "  ]  &&  return  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  [ [  " $VERIFY "  !=  [ Yy1] * ] ]  &&  return  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  [ [  " ${# check } "  = =  "40"  ] ]  &&  algo = "SHA1" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  msg = "Verifying downloaded ISO..." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  info " $msg "  &&  html " $msg " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [ [  " ${ algo ,, } "  !=  "sha256"  ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hash = $( sha1sum " $iso "  |  cut -f1 -d' ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hash = $( sha256sum " $iso "  |  cut -f1 -d' ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [ [  " $hash "  = =  " $check "  ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    info "Succesfully verified ISO!"  &&  return  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  error " The downloaded file has an invalid  $algo  checksum:  $hash  , while expected value was:  $check . Please report this at  $SUPPORT /issues " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  rm -f " $iso " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								downloadFile( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  iso = " $1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  url = " $2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  sum = " $3 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  size = " $4 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  lang = " $5 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  desc = " $6 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:50:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  rc total progress domain dots
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  rm -f " $iso " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # Check if running with interactive TTY or redirected to docker log 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [  -t 1  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    progress = "--progress=bar:noscroll" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    progress = "--progress=dot:giga" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  msg = " Downloading  $desc ... " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  html " $msg " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  domain = $( echo  " $url "  |  awk -F/ '{print $3}' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  dots = $( echo  " $domain "  |  tr -cd '.'  |  wc -c) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ( (  dots > 1  ) )  &&  domain = $( expr " $domain "  : '.*\.\(.*\..*\)' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [  -n " $domain "  ]  &&  [ [  " ${ domain ,, } "  !=  *"microsoft.com"  ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    msg = " Downloading  $desc  from  $domain ... " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  info " $msg " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  /run/progress.sh " $iso "  " $size "  " Downloading  $desc  ([P])... "  & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 01:45:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  {  wget " $url "  -O " $iso "  -q --timeout= 30  --show-progress " $progress " ;  rc = $? ;  }  ||  :
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:50:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fKill "progress.sh" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( (  rc  = =  0  ) )  &&  [  -f " $iso "  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    total = $( stat -c%s " $iso " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  [  " $total "  -gt 100000000  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 20:10:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ! verifyFile " $iso "  " $size "  " $total "  " $sum "  &&  return  1 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:50:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      html "Download finished successfully..."  &&  return  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 15:47:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( (  rc !=  4  ) ) ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    error " Failed to download  $url  , reason:  $rc " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    error " Failed to download  $url  , network failure! " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 00:50:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  rm -f " $iso " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								downloadImage( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  iso = " $1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  local  version = " $2 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  lang = " $3 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  tried = "n" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 20:06:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  local  url sum size base desc language
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  [ [  " ${ version ,, } "  = =  "http" * ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    base = $( basename " $iso " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    desc = $( fromFile " $base " ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    downloadFile " $iso "  " $version "  ""  ""  ""  " $desc "  &&  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 03:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ! validVersion " $version "  "en" ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    error " Invalid VERSION specified, value \" $version \" is not recognized! "  &&  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  desc = $( printVersion " $version "  "" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  [ [  " ${ lang ,, } "  !=  "en"  ] ]  &&  [ [  " ${ lang ,, } "  !=  "en-" * ] ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 20:06:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    language = $( getLanguage " $lang "  "desc" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 03:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ! validVersion " $version "  " $lang " ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 03:14:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      error " The  $language  language version of  $desc  is not available, please switch to English. "  &&  return  1 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 03:11:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-18 03:12:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    desc = " $desc  in  $language " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  isMido " $version "  " $lang " ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    tried = "y" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  getWindows " $version "  " $lang "  " $desc " ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      size = $( getMido " $version "  " $lang "  "size"  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      sum = $( getMido " $version "  " $lang "  "sum" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      downloadFile " $iso "  " $MIDO_URL "  " $sum "  " $size "  " $lang "  " $desc "  &&  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 22:35:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  switchEdition " $version " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  isESD " $version "  " $lang " ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  [ [  " $tried "  !=  "n"  ] ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 22:35:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      info " Failed to download  $desc , will try a diferent method now... " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    tried = "y" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  getESD " $TMP /esd "  " $version "  " $lang "  " $desc " ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ISO = " ${ ISO %.* } .esd " 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      downloadFile " $ISO "  " $ESD "  " $ESD_SUM "  " $ESD_SIZE "  " $lang "  " $desc "  &&  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      ISO = " $iso " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  for  ( ( i = 1; i<= MIRRORS; i++) ) ;  do 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    url = $( getLink " $i "  " $version "  " $lang " ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  [  -n " $url "  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      if  [ [  " $tried "  !=  "n"  ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        info " Failed to download  $desc , will try another mirror now... " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      tried = "y" 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-17 19:53:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      size = $( getSize " $i "  " $version "  " $lang " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      sum = $( getHash " $i "  " $version "  " $lang " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      downloadFile " $iso "  " $url "  " $sum "  " $size "  " $lang "  " $desc "  &&  return  0 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:48:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 19:39:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								return  0