1
0

define.sh 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619
  1. #!/usr/bin/env bash
  2. set -Eeuo pipefail
  3. : "${WIDTH:=""}"
  4. : "${HEIGHT:=""}"
  5. : "${VERIFY:=""}"
  6. : "${REGION:=""}"
  7. : "${EDITION:=""}"
  8. : "${MANUAL:=""}"
  9. : "${REMOVE:=""}"
  10. : "${VERSION:=""}"
  11. : "${DETECTED:=""}"
  12. : "${KEYBOARD:=""}"
  13. : "${LANGUAGE:=""}"
  14. : "${USERNAME:=""}"
  15. : "${PASSWORD:=""}"
  16. MIRRORS=3
  17. PLATFORM="x64"
  18. parseVersion() {
  19. if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
  20. VERSION="${VERSION:1:-1}"
  21. fi
  22. [ -z "$VERSION" ] && VERSION="win11"
  23. case "${VERSION,,}" in
  24. "11" | "11p" | "win11" | "pro11" | "win11p" | "windows11" | "windows 11" )
  25. VERSION="win11x64"
  26. ;;
  27. "11e" | "win11e" | "windows11e" | "windows 11e" )
  28. VERSION="win11x64-enterprise-eval"
  29. ;;
  30. "11i" | "11iot" | "iot11" | "win11i" | "win11-iot" | "win11x64-iot" | "win11x64-enterprise-iot-eval" )
  31. VERSION="win11x64-enterprise-iot-eval"
  32. [ -z "$DETECTED" ] && DETECTED="win11x64-iot"
  33. ;;
  34. "11l" | "11ltsc" | "ltsc11" | "win11l" | "win11-ltsc" | "win11x64-ltsc" | "win11x64-enterprise-ltsc-eval" )
  35. VERSION="win11x64-enterprise-ltsc-eval"
  36. [ -z "$DETECTED" ] && DETECTED="win11x64-ltsc"
  37. ;;
  38. "10" | "10p" | "win10" | "pro10" | "win10p" | "windows10" | "windows 10" )
  39. VERSION="win10x64"
  40. ;;
  41. "10e" | "win10e" | "windows10e" | "windows 10e" )
  42. VERSION="win10x64-enterprise-eval"
  43. ;;
  44. "10i" | "10iot" | "iot10" | "win10i" | "win10-iot" | "win10x64-iot" | "win10x64-enterprise-iot-eval" )
  45. VERSION="win10x64-enterprise-iot-eval"
  46. [ -z "$DETECTED" ] && DETECTED="win10x64-iot"
  47. ;;
  48. "10l" | "10ltsc" | "ltsc10" | "win10l" | "win10-ltsc" | "win10x64-ltsc" | "win10x64-enterprise-ltsc-eval" )
  49. VERSION="win10x64-enterprise-ltsc-eval"
  50. [ -z "$DETECTED" ] && DETECTED="win10x64-ltsc"
  51. ;;
  52. "8" | "8p" | "81" | "81p" | "pro8" | "8.1" | "win8" | "win8p" | "win81" | "win81p" | "windows 8" )
  53. VERSION="win81x64"
  54. ;;
  55. "8e" | "81e" | "8.1e" | "win8e" | "win81e" | "windows 8e" )
  56. VERSION="win81x64-enterprise-eval"
  57. ;;
  58. "7" | "7e" | "win7" | "win7e" | "windows7" | "windows 7" )
  59. VERSION="win7x64"
  60. [ -z "$DETECTED" ] && DETECTED="win7x64-enterprise"
  61. ;;
  62. "7u" | "win7u" | "windows7u" | "windows 7u" )
  63. VERSION="win7x64-ultimate"
  64. ;;
  65. "7x86" | "win7x86" | "windows7x86" | "win7x86-enterprise" )
  66. VERSION="win7x86"
  67. [ -z "$DETECTED" ] && DETECTED="win7x86-enterprise"
  68. ;;
  69. "vista" | "ve" | "6" | "winvista" | "windowsvista" | "windows vista" )
  70. VERSION="winvistax64"
  71. [ -z "$DETECTED" ] && DETECTED="winvistax64-enterprise"
  72. ;;
  73. "vistu" | "vu" | "6u" | "winvistu" | "windowsvistu" | "windows vistu" )
  74. VERSION="winvistax64-ultimate"
  75. ;;
  76. "vistax86" | "vex86" | "6x86" | "winvistax86" | "windowsvistax86" | "winvistax86-enterprise" )
  77. VERSION="winvistax86"
  78. [ -z "$DETECTED" ] && DETECTED="winvistax86-enterprise"
  79. ;;
  80. "xp" | "xp32" | "xpx86" | "5" | "5x86" | "winxp" | "winxp86" | "windowsxp" | "windows xp" )
  81. VERSION="winxpx86"
  82. ;;
  83. "xp64" | "xpx64" | "5x64" | "winxp64" | "winxpx64" | "windowsxp64" | "windowsxpx64" )
  84. VERSION="winxpx64"
  85. ;;
  86. "25" | "2025" | "win25" | "win2025" | "windows2025" | "windows 2025" )
  87. VERSION="win2025-eval"
  88. ;;
  89. "22" | "2022" | "win22" | "win2022" | "windows2022" | "windows 2022" )
  90. VERSION="win2022-eval"
  91. ;;
  92. "19" | "2019" | "win19" | "win2019" | "windows2019" | "windows 2019" )
  93. VERSION="win2019-eval"
  94. ;;
  95. "16" | "2016" | "win16" | "win2016" | "windows2016" | "windows 2016" )
  96. VERSION="win2016-eval"
  97. ;;
  98. "2012" | "2012r2" | "win2012" | "win2012r2" | "windows2012" | "windows 2012" )
  99. VERSION="win2012r2-eval"
  100. ;;
  101. "2008" | "2008r2" | "win2008" | "win2008r2" | "windows2008" | "windows 2008" )
  102. VERSION="win2008r2"
  103. ;;
  104. "2003" | "2003r2" | "win2003" | "win2003r2" | "windows2003" | "windows 2003" )
  105. VERSION="win2003r2"
  106. ;;
  107. "core11" | "core 11" )
  108. VERSION="core11"
  109. [ -z "$DETECTED" ] && DETECTED="win11x64"
  110. ;;
  111. "tiny11" | "tiny 11" )
  112. VERSION="tiny11"
  113. [ -z "$DETECTED" ] && DETECTED="win11x64"
  114. ;;
  115. "tiny10" | "tiny 10" )
  116. VERSION="tiny10"
  117. [ -z "$DETECTED" ] && DETECTED="win10x64-ltsc"
  118. ;;
  119. esac
  120. return 0
  121. }
  122. getLanguage() {
  123. local id="$1"
  124. local ret="$2"
  125. local lang=""
  126. local desc=""
  127. local short=""
  128. local culture=""
  129. case "${id,,}" in
  130. "ar" | "ar-"* )
  131. short="ar"
  132. lang="Arabic"
  133. desc="$lang"
  134. culture="ar-SA" ;;
  135. "bg" | "bg-"* )
  136. short="bg"
  137. lang="Bulgarian"
  138. desc="$lang"
  139. culture="bg-BG" ;;
  140. "cs" | "cs-"* | "cz" | "cz-"* )
  141. short="cs"
  142. lang="Czech"
  143. desc="$lang"
  144. culture="cs-CZ" ;;
  145. "da" | "da-"* | "dk" | "dk-"* )
  146. short="da"
  147. lang="Danish"
  148. desc="$lang"
  149. culture="da-DK" ;;
  150. "de" | "de-"* )
  151. short="de"
  152. lang="German"
  153. desc="$lang"
  154. culture="de-DE" ;;
  155. "el" | "el-"* | "gr" | "gr-"* )
  156. short="el"
  157. lang="Greek"
  158. desc="$lang"
  159. culture="el-GR" ;;
  160. "gb" | "en-gb" )
  161. short="en-gb"
  162. lang="English International"
  163. desc="English"
  164. culture="en-GB" ;;
  165. "en" | "en-"* )
  166. short="en"
  167. lang="English"
  168. desc="English"
  169. culture="en-US" ;;
  170. "mx" | "es-mx" )
  171. short="mx"
  172. lang="Spanish (Mexico)"
  173. desc="Spanish"
  174. culture="es-MX" ;;
  175. "es" | "es-"* )
  176. short="es"
  177. lang="Spanish"
  178. desc="$lang"
  179. culture="es-ES" ;;
  180. "et" | "et-"* )
  181. short="et"
  182. lang="Estonian"
  183. desc="$lang"
  184. culture="et-EE" ;;
  185. "fi" | "fi-"* )
  186. short="fi"
  187. lang="Finnish"
  188. desc="$lang"
  189. culture="fi-FI" ;;
  190. "ca" | "fr-ca" )
  191. short="ca"
  192. lang="French Canadian"
  193. desc="French"
  194. culture="fr-CA" ;;
  195. "fr" | "fr-"* )
  196. short="fr"
  197. lang="French"
  198. desc="$lang"
  199. culture="fr-FR" ;;
  200. "he" | "he-"* | "il" | "il-"* )
  201. short="he"
  202. lang="Hebrew"
  203. desc="$lang"
  204. culture="he-IL" ;;
  205. "hr" | "hr-"* | "cr" | "cr-"* )
  206. short="hr"
  207. lang="Croatian"
  208. desc="$lang"
  209. culture="hr-HR" ;;
  210. "hu" | "hu-"* )
  211. short="hu"
  212. lang="Hungarian"
  213. desc="$lang"
  214. culture="hu-HU" ;;
  215. "it" | "it-"* )
  216. short="it"
  217. lang="Italian"
  218. desc="$lang"
  219. culture="it-IT" ;;
  220. "ja" | "ja-"* | "jp" | "jp-"* )
  221. short="ja"
  222. lang="Japanese"
  223. desc="$lang"
  224. culture="ja-JP" ;;
  225. "ko" | "ko-"* | "kr" | "kr-"* )
  226. short="ko"
  227. lang="Korean"
  228. desc="$lang"
  229. culture="ko-KR" ;;
  230. "lt" | "lt-"* )
  231. short="lt"
  232. lang="Lithuanian"
  233. desc="$lang"
  234. culture="lt-LT" ;;
  235. "lv" | "lv-"* )
  236. short="lv"
  237. lang="Latvian"
  238. desc="$lang"
  239. culture="lv-LV" ;;
  240. "nb" | "nb-"* |"nn" | "nn-"* | "no" | "no-"* )
  241. short="no"
  242. lang="Norwegian"
  243. desc="$lang"
  244. culture="nb-NO" ;;
  245. "nl" | "nl-"* )
  246. short="nl"
  247. lang="Dutch"
  248. desc="$lang"
  249. culture="nl-NL" ;;
  250. "pl" | "pl-"* )
  251. short="pl"
  252. lang="Polish"
  253. desc="$lang"
  254. culture="pl-PL" ;;
  255. "br" | "pt-br" )
  256. short="pt"
  257. lang="Brazilian Portuguese"
  258. desc="Portuguese"
  259. culture="pt-BR" ;;
  260. "pt" | "pt-"* )
  261. short="pp"
  262. lang="Portuguese"
  263. desc="$lang"
  264. culture="pt-BR" ;;
  265. "ro" | "ro-"* )
  266. short="ro"
  267. lang="Romanian"
  268. desc="$lang"
  269. culture="ro-RO" ;;
  270. "ru" | "ru-"* )
  271. short="ru"
  272. lang="Russian"
  273. desc="$lang"
  274. culture="ru-RU" ;;
  275. "sk" | "sk-"* )
  276. short="sk"
  277. lang="Slovak"
  278. desc="$lang"
  279. culture="sk-SK" ;;
  280. "sl" | "sl-"* | "si" | "si-"* )
  281. short="sl"
  282. lang="Slovenian"
  283. desc="$lang"
  284. culture="sl-SI" ;;
  285. "sr" | "sr-"* )
  286. short="sr"
  287. lang="Serbian Latin"
  288. desc="Serbian"
  289. culture="sr-Latn-RS" ;;
  290. "sv" | "sv-"* | "se" | "se-"* )
  291. short="sv"
  292. lang="Swedish"
  293. desc="$lang"
  294. culture="sv-SE" ;;
  295. "th" | "th-"* )
  296. short="th"
  297. lang="Thai"
  298. desc="$lang"
  299. culture="th-TH" ;;
  300. "tr" | "tr-"* )
  301. short="tr"
  302. lang="Turkish"
  303. desc="$lang"
  304. culture="tr-TR" ;;
  305. "ua" | "ua-"* | "uk" | "uk-"* )
  306. short="uk"
  307. lang="Ukrainian"
  308. desc="$lang"
  309. culture="uk-UA" ;;
  310. "hk" | "zh-hk" | "cn-hk" )
  311. short="hk"
  312. lang="Chinese (Traditional)"
  313. desc="Chinese HK"
  314. culture="zh-TW" ;;
  315. "tw" | "zh-tw" | "cn-tw" )
  316. short="tw"
  317. lang="Chinese (Traditional)"
  318. desc="Chinese TW"
  319. culture="zh-TW" ;;
  320. "zh" | "zh-"* | "cn" | "cn-"* )
  321. short="cn"
  322. lang="Chinese (Simplified)"
  323. desc="Chinese"
  324. culture="zh-CN" ;;
  325. esac
  326. case "${ret,,}" in
  327. "desc" ) echo "$desc" ;;
  328. "name" ) echo "$lang" ;;
  329. "code" ) echo "$short" ;;
  330. "culture" ) echo "$culture" ;;
  331. *) echo "$desc";;
  332. esac
  333. return 0
  334. }
  335. parseLanguage() {
  336. REGION="${REGION//_/-/}"
  337. KEYBOARD="${KEYBOARD//_/-/}"
  338. LANGUAGE="${LANGUAGE//_/-/}"
  339. [ -z "$LANGUAGE" ] && LANGUAGE="en"
  340. case "${LANGUAGE,,}" in
  341. "arabic" | "arab" ) LANGUAGE="ar" ;;
  342. "bulgarian" | "bu" ) LANGUAGE="bg" ;;
  343. "chinese" | "cn" ) LANGUAGE="zh" ;;
  344. "croatian" | "cr" | "hrvatski" ) LANGUAGE="hr" ;;
  345. "czech" | "cz" | "cesky" ) LANGUAGE="cs" ;;
  346. "danish" | "dk" | "danske" ) LANGUAGE="da" ;;
  347. "dutch" | "nederlands" ) LANGUAGE="nl" ;;
  348. "english" | "gb" | "british" ) LANGUAGE="en" ;;
  349. "estonian" | "eesti" ) LANGUAGE="et" ;;
  350. "finnish" | "suomi" ) LANGUAGE="fi" ;;
  351. "french" | "français" | "francais" ) LANGUAGE="fr" ;;
  352. "german" | "deutsch" ) LANGUAGE="de" ;;
  353. "greek" | "gr" ) LANGUAGE="el" ;;
  354. "hebrew" | "il" ) LANGUAGE="he" ;;
  355. "hungarian" | "magyar" ) LANGUAGE="hu" ;;
  356. "italian" | "italiano" ) LANGUAGE="it" ;;
  357. "japanese" | "jp" ) LANGUAGE="ja" ;;
  358. "korean" | "kr" ) LANGUAGE="ko" ;;
  359. "latvian" | "latvijas" ) LANGUAGE="lv" ;;
  360. "lithuanian" | "lietuvos" ) LANGUAGE="lt" ;;
  361. "norwegian" | "no" | "nb" | "norsk" ) LANGUAGE="nn" ;;
  362. "polish" | "polski" ) LANGUAGE="pl" ;;
  363. "portuguese" | "pt" | "br" ) LANGUAGE="pt-br" ;;
  364. "português" | "portugues" ) LANGUAGE="pt-br" ;;
  365. "romanian" | "română" | "romana" ) LANGUAGE="ro" ;;
  366. "russian" | "ruski" ) LANGUAGE="ru" ;;
  367. "serbian" | "serbian latin" ) LANGUAGE="sr" ;;
  368. "slovak" | "slovenský" | "slovensky" ) LANGUAGE="sk" ;;
  369. "slovenian" | "si" | "slovenski" ) LANGUAGE="sl" ;;
  370. "spanish" | "espanol" | "español" ) LANGUAGE="es" ;;
  371. "swedish" | "se" | "svenska" ) LANGUAGE="sv" ;;
  372. "turkish" | "türk" | "turk" ) LANGUAGE="tr" ;;
  373. "thai" ) LANGUAGE="th" ;;
  374. "ukrainian" | "ua" ) LANGUAGE="uk" ;;
  375. esac
  376. local culture
  377. culture=$(getLanguage "$LANGUAGE" "culture")
  378. [ -n "$culture" ] && return 0
  379. error "Invalid LANGUAGE specified, value \"$LANGUAGE\" is not recognized!"
  380. return 1
  381. }
  382. printVersion() {
  383. local id="$1"
  384. local desc="$2"
  385. case "${id,,}" in
  386. "tiny11"* ) desc="Tiny 11" ;;
  387. "tiny10"* ) desc="Tiny 10" ;;
  388. "core11"* ) desc="Core 11" ;;
  389. "win7"* ) desc="Windows 7" ;;
  390. "win8"* ) desc="Windows 8" ;;
  391. "win10"* ) desc="Windows 10" ;;
  392. "win11"* ) desc="Windows 11" ;;
  393. "winxp"* ) desc="Windows XP" ;;
  394. "win9x"* ) desc="Windows ME" ;;
  395. "win98"* ) desc="Windows 98" ;;
  396. "win95"* ) desc="Windows 95" ;;
  397. "win2k"* ) desc="Windows 2000" ;;
  398. "winvista"* ) desc="Windows Vista" ;;
  399. "win2003"* ) desc="Windows Server 2003" ;;
  400. "win2008"* ) desc="Windows Server 2008" ;;
  401. "win2012"* ) desc="Windows Server 2012" ;;
  402. "win2016"* ) desc="Windows Server 2016" ;;
  403. "win2019"* ) desc="Windows Server 2019" ;;
  404. "win2022"* ) desc="Windows Server 2022" ;;
  405. "win2025"* ) desc="Windows Server 2025" ;;
  406. esac
  407. if [ -z "$desc" ]; then
  408. desc="Windows"
  409. [[ "${PLATFORM,,}" != "x64" ]] && desc+=" for ${PLATFORM}"
  410. fi
  411. echo "$desc"
  412. return 0
  413. }
  414. printEdition() {
  415. local id="$1"
  416. local desc="$2"
  417. local result=""
  418. local edition=""
  419. result=$(printVersion "$id" "x")
  420. [[ "$result" == "x" ]] && echo "$desc" && return 0
  421. case "${id,,}" in
  422. *"-home" )
  423. edition="Home"
  424. ;;
  425. *"-starter" )
  426. edition="Starter"
  427. ;;
  428. *"-ultimate" )
  429. edition="Ultimate"
  430. ;;
  431. *"-enterprise" )
  432. edition="Enterprise"
  433. ;;
  434. *"-education" )
  435. edition="Education"
  436. ;;
  437. *"-iot" | *"-iot-eval" )
  438. edition="LTSC"
  439. ;;
  440. *"-ltsc" | *"-ltsc-eval" )
  441. edition="LTSC"
  442. ;;
  443. *"-enterprise-eval" )
  444. edition="Enterprise (Evaluation)"
  445. ;;
  446. "win7"* )
  447. edition="Professional"
  448. ;;
  449. "win8"* | "win10"* | "win11"* )
  450. edition="Pro"
  451. ;;
  452. "winxp"* )
  453. edition="Professional"
  454. ;;
  455. "winvista"* )
  456. edition="Business"
  457. ;;
  458. "win2025"* | "win2022"* | "win2019"* | "win2016"* )
  459. edition="Standard"
  460. ;;
  461. "win2012"* | "win2008"* | "win2003"* )
  462. edition="Standard"
  463. ;;
  464. esac
  465. [ -n "$edition" ] && result+=" $edition"
  466. echo "$result"
  467. return 0
  468. }
  469. fromFile() {
  470. local id=""
  471. local desc="$1"
  472. local file="${1,,}"
  473. local arch="${PLATFORM,,}"
  474. file="${file//-/_}"
  475. file="${file// /_}"
  476. case "$file" in
  477. *"_x64_"* | *"_x64."*)
  478. arch="x64"
  479. ;;
  480. *"_x86_"* | *"_x86."*)
  481. arch="x86"
  482. ;;
  483. *"_arm64_"* | *"_arm64."*)
  484. arch="arm64"
  485. ;;
  486. esac
  487. local add=""
  488. [[ "$arch" != "x64" ]] && add="$arch"
  489. case "$file" in
  490. "win7"* | "win_7"* | *"windows7"* | *"windows_7"* )
  491. id="win7${arch}"
  492. ;;
  493. "win8"* | "win_8"* | *"windows8"* | *"windows_8"* )
  494. id="win81${arch}"
  495. ;;
  496. "win10"*| "win_10"* | *"windows10"* | *"windows_10"* )
  497. id="win10${arch}"
  498. ;;
  499. "win11"* | "win_11"* | *"windows11"* | *"windows_11"* )
  500. id="win11${arch}"
  501. ;;
  502. *"winxp"* | *"win_xp"* | *"windowsxp"* | *"windows_xp"* )
  503. id="winxpx86"
  504. ;;
  505. *"winvista"* | *"win_vista"* | *"windowsvista"* | *"windows_vista"* )
  506. id="winvista${arch}"
  507. ;;
  508. "tiny11core"* | "tiny11_core"* | "tiny_11_core"* )
  509. id="core11"
  510. ;;
  511. "tiny11"* | "tiny_11"* )
  512. id="tiny11"
  513. ;;
  514. "tiny10"* | "tiny_10"* )
  515. id="tiny10"
  516. ;;
  517. *"server2025"* | *"server_2025"* )
  518. id="win2025${add}"
  519. ;;
  520. *"server2022"* | *"server_2022"* )
  521. id="win2022${add}"
  522. ;;
  523. *"server2019"* | *"server_2019"* )
  524. id="win2019${add}"
  525. ;;
  526. *"server2016"* | *"server_2016"* )
  527. id="win2016${add}"
  528. ;;
  529. *"server2012"* | *"server_2012"* )
  530. id="win2012r2${add}"
  531. ;;
  532. *"server2008"* | *"server_2008"* )
  533. id="win2008r2${add}"
  534. ;;
  535. *"server2003"* | *"server_2003"* )
  536. id="win2003r2${add}"
  537. ;;
  538. esac
  539. if [ -n "$id" ]; then
  540. desc=$(printVersion "$id" "$desc")
  541. fi
  542. echo "$desc"
  543. return 0
  544. }
  545. fromName() {
  546. local id=""
  547. local name="$1"
  548. local arch="$2"
  549. local add=""
  550. [[ "$arch" != "x64" ]] && add="$arch"
  551. case "${name,,}" in
  552. *"windows 7"* ) id="win7${arch}" ;;
  553. *"windows 8"* ) id="win81${arch}" ;;
  554. *"windows 10"* ) id="win10${arch}" ;;
  555. *"optimum 10"* ) id="win10${arch}" ;;
  556. *"windows 11"* ) id="win11${arch}" ;;
  557. *"optimum 11"* ) id="win11${arch}" ;;
  558. *"windows vista"* ) id="winvista${arch}" ;;
  559. *"server 2025"* ) id="win2025${add}" ;;
  560. *"server 2022"* ) id="win2022${add}" ;;
  561. *"server 2019"* ) id="win2019${add}" ;;
  562. *"server 2016"* ) id="win2016${add}" ;;
  563. *"server 2012"* ) id="win2012r2${add}" ;;
  564. *"server 2008"* ) id="win2008r2${add}" ;;
  565. *"server 2003"* ) id="win2003r2${add}" ;;
  566. esac
  567. echo "$id"
  568. return 0
  569. }
  570. getVersion() {
  571. local id
  572. local name="$1"
  573. local arch="$2"
  574. id=$(fromName "$name" "$arch")
  575. case "${id,,}" in
  576. "win7"* | "winvista"* )
  577. case "${name,,}" in
  578. *" home"* ) id="$id-home" ;;
  579. *" starter"* ) id="$id-starter" ;;
  580. *" ultimate"* ) id="$id-ultimate" ;;
  581. *" enterprise"* ) id="$id-enterprise" ;;
  582. esac
  583. ;;
  584. "win8"* )
  585. case "${name,,}" in
  586. *" enterprise evaluation"* ) id="$id-enterprise-eval" ;;
  587. *" enterprise"* ) id="$id-enterprise" ;;
  588. esac
  589. ;;
  590. "win10"* | "win11"* )
  591. case "${name,,}" in
  592. *" iot"* ) id="$id-iot" ;;
  593. *" ltsc"* ) id="$id-ltsc" ;;
  594. *" home"* ) id="$id-home" ;;
  595. *" education"* ) id="$id-education" ;;
  596. *" enterprise evaluation"* ) id="$id-enterprise-eval" ;;
  597. *" enterprise"* ) id="$id-enterprise" ;;
  598. esac
  599. ;;
  600. "win2025"* | "win2022"* | "win2019"* | "win2016"* | "win2012"* | "win2008"* | "win2003"* )
  601. case "${name,,}" in
  602. *" evaluation"* ) id="$id-eval" ;;
  603. esac
  604. ;;
  605. esac
  606. echo "$id"
  607. return 0
  608. }
  609. switchEdition() {
  610. local id="$1"
  611. case "${id,,}" in
  612. "win11${PLATFORM,,}-enterprise-eval" )
  613. DETECTED="win11${PLATFORM,,}-enterprise"
  614. ;;
  615. "win10${PLATFORM,,}-enterprise-eval" )
  616. DETECTED="win10${PLATFORM,,}-enterprise"
  617. ;;
  618. "win81${PLATFORM,,}-enterprise-eval" )
  619. DETECTED="win81${PLATFORM,,}-enterprise"
  620. ;;
  621. "win2025-eval" ) DETECTED="win2025" ;;
  622. "win2022-eval" ) DETECTED="win2022" ;;
  623. "win2019-eval" ) DETECTED="win2019" ;;
  624. "win2016-eval" ) DETECTED="win2016" ;;
  625. "win2012r2-eval" ) DETECTED="win2012r2" ;;
  626. "win2008r2-eval" ) DETECTED="win2008r2" ;;
  627. esac
  628. return 0
  629. }
  630. getMido() {
  631. local id="$1"
  632. local lang="$2"
  633. local ret="$3"
  634. local sum=""
  635. local size=""
  636. [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0
  637. case "${id,,}" in
  638. "win11x64" )
  639. size=5819484160
  640. sum="b56b911bf18a2ceaeb3904d87e7c770bdf92d3099599d61ac2497b91bf190b11"
  641. ;;
  642. "win11x64-enterprise-eval" )
  643. size=4295096320
  644. sum="dad633276073f14f3e0373ef7e787569e216d54942ce522b39451c8f2d38ad43"
  645. ;;
  646. "win11x64-enterprise-ltsc-eval" )
  647. size=5060020224
  648. sum="2cee70bd183df42b92a2e0da08cc2bb7a2a9ce3a3841955a012c0f77aeb3cb29"
  649. ;;
  650. "win11x64-enterprise-iot-eval" )
  651. size=5060020224
  652. sum="2cee70bd183df42b92a2e0da08cc2bb7a2a9ce3a3841955a012c0f77aeb3cb29"
  653. ;;
  654. "win10x64" )
  655. size=6140975104
  656. sum="a6f470ca6d331eb353b815c043e327a347f594f37ff525f17764738fe812852e"
  657. ;;
  658. "win10x64-enterprise-eval" )
  659. size=5550497792
  660. sum="ef7312733a9f5d7d51cfa04ac497671995674ca5e1058d5164d6028f0938d668"
  661. ;;
  662. "win10x64-enterprise-ltsc-eval" )
  663. size=4898582528
  664. sum="e4ab2e3535be5748252a8d5d57539a6e59be8d6726345ee10e7afd2cb89fefb5"
  665. ;;
  666. "win81x64-enterprise-eval" )
  667. size=3961473024
  668. sum="2dedd44c45646c74efc5a028f65336027e14a56f76686a4631cf94ffe37c72f2"
  669. ;;
  670. "win2025-eval" )
  671. size=5307996160
  672. sum="16442d1c0509bcbb25b715b1b322a15fb3ab724a42da0f384b9406ca1c124ed4"
  673. ;;
  674. "win2022-eval" )
  675. size=5044094976
  676. sum="3e4fa6d8507b554856fc9ca6079cc402df11a8b79344871669f0251535255325"
  677. ;;
  678. "win2019-eval" )
  679. size=5652088832
  680. sum="6dae072e7f78f4ccab74a45341de0d6e2d45c39be25f1f5920a2ab4f51d7bcbb"
  681. ;;
  682. "win2016-eval" )
  683. size=6972221440
  684. sum="1ce702a578a3cb1ac3d14873980838590f06d5b7101c5daaccbac9d73f1fb50f"
  685. ;;
  686. "win2012r2-eval" )
  687. size=4542291968
  688. sum="6612b5b1f53e845aacdf96e974bb119a3d9b4dcb5b82e65804ab7e534dc7b4d5"
  689. ;;
  690. "win2008r2" )
  691. size=3166840832
  692. sum="30832ad76ccfa4ce48ccb936edefe02079d42fb1da32201bf9e3a880c8ed6312"
  693. ;;
  694. esac
  695. case "${ret,,}" in
  696. "sum" ) echo "$sum" ;;
  697. "size" ) echo "$size" ;;
  698. *) echo "";;
  699. esac
  700. return 0
  701. }
  702. getLink1() {
  703. # Fallbacks for users who cannot connect to the Microsoft servers
  704. local id="$1"
  705. local lang="$2"
  706. local ret="$3"
  707. local url=""
  708. local sum=""
  709. local size=""
  710. local host="https://dl.bobpony.com/windows"
  711. [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0
  712. case "${id,,}" in
  713. "win11x64" | "win11x64-enterprise" | "win11x64-enterprise-eval" )
  714. size=5332989952
  715. sum="aa1ad990f930d907b7a34ea897abbb0dfbe47552ca8acc146f92e40381839e05"
  716. url="11/en-us_windows_11_24h2_x64.iso"
  717. ;;
  718. "win11x64-iot" | "win11x64-enterprise-iot-eval" )
  719. [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0
  720. size=5144817664
  721. sum="4f59662a96fc1da48c1b415d6c369d08af55ddd64e8f1c84e0166d9e50405d7a"
  722. url="11/X23-81951_26100.1742.240906-0331.ge_release_svc_refresh_CLIENT_ENTERPRISES_OEM_x64FRE_en-us.iso"
  723. ;;
  724. "win11x64-ltsc" | "win11x64-enterprise-ltsc-eval" )
  725. [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0
  726. size=5144817664
  727. sum="4f59662a96fc1da48c1b415d6c369d08af55ddd64e8f1c84e0166d9e50405d7a"
  728. url="11/X23-81951_26100.1742.240906-0331.ge_release_svc_refresh_CLIENT_ENTERPRISES_OEM_x64FRE_en-us.iso"
  729. ;;
  730. "win10x64" | "win10x64-enterprise" | "win10x64-enterprise-eval" )
  731. size=5535252480
  732. sum="557871965263d0fd0a1ea50b5d0d0d7cb04a279148ca905c1c675c9bc0d5486c"
  733. url="10/en-us_windows_10_22h2_x64.iso"
  734. ;;
  735. "win10x64-iot" | "win10x64-enterprise-iot-eval" )
  736. size=4851668992
  737. sum="a0334f31ea7a3e6932b9ad7206608248f0bd40698bfb8fc65f14fc5e4976c160"
  738. url="10/en-us_windows_10_iot_enterprise_ltsc_2021_x64_dvd_257ad90f.iso"
  739. ;;
  740. "win10x64-ltsc" | "win10x64-enterprise-ltsc-eval" )
  741. size=4899461120
  742. sum="c90a6df8997bf49e56b9673982f3e80745058723a707aef8f22998ae6479597d"
  743. url="10/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso"
  744. ;;
  745. "win81x64" )
  746. size=4320526336
  747. sum="d8333cf427eb3318ff6ab755eb1dd9d433f0e2ae43745312c1cd23e83ca1ce51"
  748. url="8.x/8.1/en_windows_8.1_with_update_x64_dvd_6051480.iso"
  749. ;;
  750. "win81x64-enterprise" | "win81x64-enterprise-eval" )
  751. size=4139163648
  752. sum="c3c604c03677504e8905090a8ce5bb1dde76b6fd58e10f32e3a25bef21b2abe1"
  753. url="8.x/8.1/en_windows_8.1_enterprise_with_update_x64_dvd_6054382.iso"
  754. ;;
  755. "win2025" | "win2025-eval" )
  756. size=5307176960
  757. sum="2293897341febdcea599f5412300b470b5288c6fd2b89666a7b27d283e8d3cf3"
  758. url="server/2025/en-us_windows_server_2025_preview_x64_dvd_ce9eb1a5.iso"
  759. ;;
  760. "win2022" | "win2022-eval" )
  761. size=5365624832
  762. sum="c3c57bb2cf723973a7dcfb1a21e97dfa035753a7f111e348ad918bb64b3114db"
  763. url="server/2022/en-us_windows_server_2022_updated_jan_2024_x64_dvd_2b7a0c9f.iso"
  764. ;;
  765. "win2019" | "win2019-eval" )
  766. size=5575774208
  767. sum="0067afe7fdc4e61f677bd8c35a209082aa917df9c117527fc4b2b52a447e89bb"
  768. url="server/2019/en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso"
  769. ;;
  770. "win2016" | "win2016-eval" )
  771. size=6006587392
  772. sum="af06e5483c786c023123e325cea4775050324d9e1366f46850b515ae43f764be"
  773. url="server/2016/en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso"
  774. ;;
  775. "win2012r2" | "win2012r2-eval" )
  776. size=5397889024
  777. sum="f351e89eb88a96af4626ceb3450248b8573e3ed5924a4e19ea891e6003b62e4e"
  778. url="server/2012r2/en_windows_server_2012_r2_with_update_x64_dvd_6052708-004.iso"
  779. ;;
  780. "win2008r2" | "win2008r2-eval" )
  781. size=3166584832
  782. sum="dfd9890881b7e832a927c38310fb415b7ea62ac5a896671f2ce2a111998f0df8"
  783. url="server/2008r2/en_windows_server_2008_r2_with_sp1_x64_dvd_617601-018.iso"
  784. ;;
  785. "win7x64" | "win7x64-enterprise" )
  786. size=3182604288
  787. sum="ee69f3e9b86ff973f632db8e01700c5724ef78420b175d25bae6ead90f6805a7"
  788. url="7/en_windows_7_enterprise_with_sp1_x64_dvd_u_677651.iso"
  789. ;;
  790. "win7x64-ultimate" )
  791. size=3320836096
  792. sum="0b738b55a5ea388ad016535a5c8234daf2e5715a0638488ddd8a228a836055a1"
  793. url="7/en_windows_7_with_sp1_x64.iso"
  794. ;;
  795. "win7x86" | "win7x86-enterprise" )
  796. size=2434502656
  797. sum="8bdd46ff8cb8b8de9c4aba02706629c8983c45e87da110e64e13be17c8434dad"
  798. url="7/en_windows_7_enterprise_with_sp1_x86_dvd_u_677710.iso"
  799. ;;
  800. "win7x86-ultimate" )
  801. size=2564411392
  802. sum="99f3369c90160816be07093dbb0ac053e0a84e52d6ed1395c92ae208ccdf67e5"
  803. url="7/en_windows_7_with_sp1_x86.iso"
  804. ;;
  805. "winvistax64-ultimate" )
  806. size=3861460992
  807. sum="edf9f947c5791469fd7d2d40a5dcce663efa754f91847aa1d28ed7f585675b78"
  808. url="vista/en_windows_vista_sp2_x64_dvd_342267.iso"
  809. ;;
  810. "winvistax86-ultimate" )
  811. size=3243413504
  812. sum="9c36fed4255bd05a8506b2da88f9aad73643395e155e609398aacd2b5276289c"
  813. url="vista/en_windows_vista_with_sp2_x86_dvd_342266.iso"
  814. ;;
  815. "winxpx86" )
  816. size=617756672
  817. sum="62b6c91563bad6cd12a352aa018627c314cfc5162d8e9f8af0756a642e602a46"
  818. url="xp/professional/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
  819. ;;
  820. "winxpx64" )
  821. size=614166528
  822. sum="8fac68e1e56c64ad9a2aa0ad464560282e67fa4f4dd51d09a66f4e548eb0f2d6"
  823. url="xp/professional/en_win_xp_pro_x64_vl.iso"
  824. ;;
  825. esac
  826. case "${ret,,}" in
  827. "sum" ) echo "$sum" ;;
  828. "size" ) echo "$size" ;;
  829. *) [ -n "$url" ] && echo "$host/$url";;
  830. esac
  831. return 0
  832. }
  833. getLink2() {
  834. local id="$1"
  835. local lang="$2"
  836. local ret="$3"
  837. local url=""
  838. local sum=""
  839. local size=""
  840. local host="https://files.dog/MSDN"
  841. [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0
  842. case "${id,,}" in
  843. "win81x64" )
  844. size=4320526336
  845. sum="d8333cf427eb3318ff6ab755eb1dd9d433f0e2ae43745312c1cd23e83ca1ce51"
  846. url="Windows%208.1%20with%20Update/en_windows_8.1_with_update_x64_dvd_6051480.iso"
  847. ;;
  848. "win81x64-enterprise" | "win81x64-enterprise-eval" )
  849. size=4139163648
  850. sum="c3c604c03677504e8905090a8ce5bb1dde76b6fd58e10f32e3a25bef21b2abe1"
  851. url="Windows%208.1%20with%20Update/en_windows_8.1_enterprise_with_update_x64_dvd_6054382.iso"
  852. ;;
  853. "win2012r2" | "win2012r2-eval" )
  854. size=5397889024
  855. sum="f351e89eb88a96af4626ceb3450248b8573e3ed5924a4e19ea891e6003b62e4e"
  856. url="Windows%20Server%202012%20R2%20with%20Update/en_windows_server_2012_r2_with_update_x64_dvd_6052708.iso"
  857. ;;
  858. "win2008r2" | "win2008r2-eval" )
  859. size=3166584832
  860. sum="dfd9890881b7e832a927c38310fb415b7ea62ac5a896671f2ce2a111998f0df8"
  861. url="Windows%20Server%202008%20R2/en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso"
  862. ;;
  863. "win7x64" | "win7x64-enterprise" )
  864. size=3182604288
  865. sum="ee69f3e9b86ff973f632db8e01700c5724ef78420b175d25bae6ead90f6805a7"
  866. url="Windows%207/en_windows_7_enterprise_with_sp1_x64_dvd_u_677651.iso"
  867. ;;
  868. "win7x64-ultimate" )
  869. size=3320903680
  870. sum="36f4fa2416d0982697ab106e3a72d2e120dbcdb6cc54fd3906d06120d0653808"
  871. url="Windows%207/en_windows_7_ultimate_with_sp1_x64_dvd_u_677332.iso"
  872. ;;
  873. "win7x86" | "win7x86-enterprise" )
  874. size=2434502656
  875. sum="8bdd46ff8cb8b8de9c4aba02706629c8983c45e87da110e64e13be17c8434dad"
  876. url="Windows%207/en_windows_7_enterprise_with_sp1_x86_dvd_u_677710.iso"
  877. ;;
  878. "win7x86-ultimate" )
  879. size=2564476928
  880. sum="e2c009a66d63a742941f5087acae1aa438dcbe87010bddd53884b1af6b22c940"
  881. url="Windows%207/en_windows_7_ultimate_with_sp1_x86_dvd_u_677460.iso"
  882. ;;
  883. "winvistax64" | "winvistax64-enterprise" )
  884. size=3205953536
  885. sum="0a0cd511b3eac95c6f081419c9c65b12317b9d6a8d9707f89d646c910e788016"
  886. url="Windows%20Vista/en_windows_vista_enterprise_sp2_x64_dvd_342332.iso"
  887. ;;
  888. "winvistax64-ultimate" )
  889. size=3861460992
  890. sum="edf9f947c5791469fd7d2d40a5dcce663efa754f91847aa1d28ed7f585675b78"
  891. url="Windows%20Vista/en_windows_vista_sp2_x64_dvd_342267.iso"
  892. ;;
  893. "winvistax86" | "winvistax86-enterprise" )
  894. size=2420981760
  895. sum="54e2720004041e7db988a391543ea5228b0affc28efcf9303d2d0ff9402067f5"
  896. url="Windows%20Vista/en_windows_vista_enterprise_sp2_x86_dvd_342329.iso"
  897. ;;
  898. "winvistax86-ultimate" )
  899. size=3243413504
  900. sum="9c36fed4255bd05a8506b2da88f9aad73643395e155e609398aacd2b5276289c"
  901. url="Windows%20Vista/en_windows_vista_with_sp2_x86_dvd_342266.iso"
  902. ;;
  903. "win2003r2" )
  904. size=652367872
  905. sum="74245cba888f935b138b106c2744bec7f392925b472358960a0b5643cd6abb32"
  906. url="Windows%20Server%202003%20R2/en_win_srv_2003_r2_standard_x64_with_sp2_cd1_x13-05757.iso"
  907. ;;
  908. "winxpx86" )
  909. size=617756672
  910. sum="62b6c91563bad6cd12a352aa018627c314cfc5162d8e9f8af0756a642e602a46"
  911. url="Windows%20XP/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
  912. ;;
  913. "winxpx64" )
  914. size=614166528
  915. sum="8fac68e1e56c64ad9a2aa0ad464560282e67fa4f4dd51d09a66f4e548eb0f2d6"
  916. url="Windows%20XP/en_win_xp_pro_x64_vl.iso"
  917. ;;
  918. esac
  919. case "${ret,,}" in
  920. "sum" ) echo "$sum" ;;
  921. "size" ) echo "$size" ;;
  922. *) [ -n "$url" ] && echo "$host/$url";;
  923. esac
  924. return 0
  925. }
  926. getLink3() {
  927. local id="$1"
  928. local lang="$2"
  929. local ret="$3"
  930. local url=""
  931. local sum=""
  932. local size=""
  933. local host="https://archive.org/download"
  934. [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0
  935. case "${id,,}" in
  936. "core11" )
  937. size=2159738880
  938. sum="78f0f44444ff95b97125b43e560a72e0d6ce0a665cf9f5573bf268191e5510c1"
  939. url="tiny-11-core-x-64-beta-1/tiny11%20core%20x64%20beta%201.iso"
  940. ;;
  941. "tiny11" )
  942. size=3788177408
  943. sum="a028800a91addc35d8ae22dce7459b67330f7d69d2f11c70f53c0fdffa5b4280"
  944. url="tiny11-2311/tiny11%202311%20x64.iso"
  945. ;;
  946. "tiny10" )
  947. size=3839819776
  948. sum="a11116c0645d892d6a5a7c585ecc1fa13aa66f8c7cc6b03bf1f27bd16860cc35"
  949. url="tiny-10-23-h2/tiny10%20x64%2023h2.iso"
  950. ;;
  951. "winxpx86" )
  952. size=617756672
  953. sum="62b6c91563bad6cd12a352aa018627c314cfc5162d8e9f8af0756a642e602a46"
  954. url="XPPRO_SP3_ENU/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
  955. ;;
  956. esac
  957. case "${ret,,}" in
  958. "sum" ) echo "$sum" ;;
  959. "size" ) echo "$size" ;;
  960. *) [ -n "$url" ] && echo "$host/$url";;
  961. esac
  962. return 0
  963. }
  964. getValue() {
  965. local val=""
  966. local id="$2"
  967. local lang="$3"
  968. local type="$4"
  969. local func="getLink$1"
  970. if [ "$1" -gt 0 ] && [ "$1" -le "$MIRRORS" ]; then
  971. val=$($func "$id" "$lang" "$type")
  972. fi
  973. echo "$val"
  974. return 0
  975. }
  976. getLink() {
  977. local url
  978. url=$(getValue "$1" "$2" "$3" "")
  979. echo "$url"
  980. return 0
  981. }
  982. getHash() {
  983. local sum
  984. sum=$(getValue "$1" "$2" "$3" "sum")
  985. echo "$sum"
  986. return 0
  987. }
  988. getSize() {
  989. local size
  990. size=$(getValue "$1" "$2" "$3" "size")
  991. echo "$size"
  992. return 0
  993. }
  994. isMido() {
  995. local id="$1"
  996. local lang="$2"
  997. local sum
  998. sum=$(getMido "$id" "en" "sum")
  999. [ -n "$sum" ] && return 0
  1000. return 1
  1001. }
  1002. isESD() {
  1003. local id="$1"
  1004. local lang="$2"
  1005. case "${id,,}" in
  1006. "win11${PLATFORM,,}" | "win10${PLATFORM,,}" )
  1007. return 0
  1008. ;;
  1009. "win11${PLATFORM,,}-enterprise" | "win11${PLATFORM,,}-enterprise-eval")
  1010. return 0
  1011. ;;
  1012. "win10${PLATFORM,,}-enterprise" | "win10${PLATFORM,,}-enterprise-eval" )
  1013. return 0
  1014. ;;
  1015. esac
  1016. return 1
  1017. }
  1018. validVersion() {
  1019. local id="$1"
  1020. local lang="$2"
  1021. local url
  1022. isESD "$id" "$lang" && return 0
  1023. isMido "$id" "$lang" && return 0
  1024. for ((i=1;i<=MIRRORS;i++)); do
  1025. url=$(getLink "$i" "$id" "$lang")
  1026. [ -n "$url" ] && return 0
  1027. done
  1028. return 1
  1029. }
  1030. addFolder() {
  1031. local src="$1"
  1032. local folder="/oem"
  1033. [ ! -d "$folder" ] && folder="/OEM"
  1034. [ ! -d "$folder" ] && folder="$STORAGE/oem"
  1035. [ ! -d "$folder" ] && folder="$STORAGE/OEM"
  1036. [ ! -d "$folder" ] && return 0
  1037. local msg="Adding OEM folder to image..."
  1038. info "$msg" && html "$msg"
  1039. local dest="$src/\$OEM\$/\$1/OEM"
  1040. mkdir -p "$dest" || return 1
  1041. cp -Lr "$folder/." "$dest" || return 1
  1042. local file
  1043. file=$(find "$dest" -maxdepth 1 -type f -iname install.bat | head -n 1)
  1044. [ -f "$file" ] && unix2dos -q "$file"
  1045. return 0
  1046. }
  1047. prepareInstall() {
  1048. local dir="$2"
  1049. local desc="$3"
  1050. local arch="$4"
  1051. local key="$5"
  1052. local driver="$6"
  1053. local drivers="/tmp/drivers"
  1054. rm -rf "$drivers"
  1055. mkdir -p "$drivers"
  1056. ETFS="[BOOT]/Boot-NoEmul.img"
  1057. if [ ! -f "$dir/$ETFS" ] || [ ! -s "$dir/$ETFS" ]; then
  1058. error "Failed to locate file \"$ETFS\" in $desc ISO image!" && return 1
  1059. fi
  1060. local msg="Adding drivers to image..."
  1061. info "$msg" && html "$msg"
  1062. if ! bsdtar -xf /drivers.txz -C "$drivers"; then
  1063. error "Failed to extract drivers!" && return 1
  1064. fi
  1065. local target
  1066. [[ "${arch,,}" == "x86" ]] && target="$dir/I386" || target="$dir/AMD64"
  1067. if [ ! -f "$drivers/viostor/$driver/$arch/viostor.sys" ]; then
  1068. error "Failed to locate required storage drivers!" && return 1
  1069. fi
  1070. cp -L "$drivers/viostor/$driver/$arch/viostor.sys" "$target" || return 1
  1071. mkdir -p "$dir/\$OEM\$/\$1/Drivers/viostor" || return 1
  1072. cp -L "$drivers/viostor/$driver/$arch/viostor.cat" "$dir/\$OEM\$/\$1/Drivers/viostor" || return 1
  1073. cp -L "$drivers/viostor/$driver/$arch/viostor.inf" "$dir/\$OEM\$/\$1/Drivers/viostor" || return 1
  1074. cp -L "$drivers/viostor/$driver/$arch/viostor.sys" "$dir/\$OEM\$/\$1/Drivers/viostor" || return 1
  1075. if [ ! -f "$drivers/NetKVM/$driver/$arch/netkvm.sys" ]; then
  1076. error "Failed to locate required network drivers!" && return 1
  1077. fi
  1078. mkdir -p "$dir/\$OEM\$/\$1/Drivers/NetKVM" || return 1
  1079. cp -L "$drivers/NetKVM/$driver/$arch/netkvm.cat" "$dir/\$OEM\$/\$1/Drivers/NetKVM" || return 1
  1080. cp -L "$drivers/NetKVM/$driver/$arch/netkvm.inf" "$dir/\$OEM\$/\$1/Drivers/NetKVM" || return 1
  1081. cp -L "$drivers/NetKVM/$driver/$arch/netkvm.sys" "$dir/\$OEM\$/\$1/Drivers/NetKVM" || return 1
  1082. if [ ! -f "$target/TXTSETUP.SIF" ]; then
  1083. error "The file TXTSETUP.SIF could not be found!" && return 1
  1084. fi
  1085. sed -i '/^\[SCSI.Load\]/s/$/\nviostor=viostor.sys,4/' "$target/TXTSETUP.SIF"
  1086. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\nviostor.sys=1,,,,,,4_,4,1,,,1,4/' "$target/TXTSETUP.SIF"
  1087. sed -i '/^\[SCSI\]/s/$/\nviostor=\"Red Hat VirtIO SCSI Disk Device\"/' "$target/TXTSETUP.SIF"
  1088. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00000000=\"viostor\"/' "$target/TXTSETUP.SIF"
  1089. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00020000=\"viostor\"/' "$target/TXTSETUP.SIF"
  1090. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00021AF4=\"viostor\"/' "$target/TXTSETUP.SIF"
  1091. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00000000=\"viostor\"/' "$target/TXTSETUP.SIF"
  1092. if [ ! -d "$drivers/sata/xp/$arch" ]; then
  1093. error "Failed to locate required SATA drivers!" && return 1
  1094. fi
  1095. mkdir -p "$dir/\$OEM\$/\$1/Drivers/sata" || return 1
  1096. cp -Lr "$drivers/sata/xp/$arch/." "$dir/\$OEM\$/\$1/Drivers/sata" || return 1
  1097. cp -Lr "$drivers/sata/xp/$arch/." "$target" || return 1
  1098. sed -i '/^\[SCSI.Load\]/s/$/\niaStor=iaStor.sys,4/' "$target/TXTSETUP.SIF"
  1099. sed -i '/^\[FileFlags\]/s/$/\niaStor.sys = 16/' "$target/TXTSETUP.SIF"
  1100. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.cat = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  1101. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.inf = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  1102. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.sys = 1,,,,,,4_,4,1,,,1,4/' "$target/TXTSETUP.SIF"
  1103. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.sys = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  1104. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaahci.cat = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  1105. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaAHCI.inf = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  1106. sed -i '/^\[SCSI\]/s/$/\niaStor=\"Intel\(R\) SATA RAID\/AHCI Controller\"/' "$target/TXTSETUP.SIF"
  1107. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_8086\&DEV_2922\&CC_0106=\"iaStor\"/' "$target/TXTSETUP.SIF"
  1108. rm -rf "$drivers"
  1109. local pid file setup
  1110. setup=$(find "$target" -maxdepth 1 -type f -iname setupp.ini | head -n 1)
  1111. pid=$(<"$setup")
  1112. pid="${pid:(-4)}"
  1113. pid="${pid:0:3}"
  1114. if [[ "$pid" == "270" ]]; then
  1115. warn "this version of $desc requires a volume license key (VLK), it will ask for one during installation."
  1116. fi
  1117. if ! addFolder "$dir"; then
  1118. error "Failed to add OEM folder to image!" && return 1
  1119. fi
  1120. local oem=""
  1121. local install="$dir/\$OEM\$/\$1/OEM/install.bat"
  1122. [ -f "$install" ] && oem="\"Script\"=\"cmd /C start \\\"Install\\\" \\\"cmd /C C:\\\\OEM\\\\install.bat\\\"\""
  1123. [ -z "$WIDTH" ] && WIDTH="1280"
  1124. [ -z "$HEIGHT" ] && HEIGHT="720"
  1125. XHEX=$(printf '%x\n' "$WIDTH")
  1126. YHEX=$(printf '%x\n' "$HEIGHT")
  1127. local username="Docker"
  1128. local password="*"
  1129. [ -n "$PASSWORD" ] && password="$PASSWORD"
  1130. [ -n "$USERNAME" ] && username=$(echo "$USERNAME" | sed 's/[^[:alnum:]@!._-]//g')
  1131. find "$target" -maxdepth 1 -type f -iname winnt.sif -exec rm {} \;
  1132. { echo "[Data]"
  1133. echo " AutoPartition=1"
  1134. echo " MsDosInitiated=\"0\""
  1135. echo " UnattendedInstall=\"Yes\""
  1136. echo " AutomaticUpdates=\"Yes\""
  1137. echo ""
  1138. echo "[Unattended]"
  1139. echo " UnattendSwitch=Yes"
  1140. echo " UnattendMode=FullUnattended"
  1141. echo " FileSystem=NTFS"
  1142. echo " OemSkipEula=Yes"
  1143. echo " OemPreinstall=Yes"
  1144. echo " Repartition=Yes"
  1145. echo " WaitForReboot=\"No\""
  1146. echo " DriverSigningPolicy=\"Ignore\""
  1147. echo " NonDriverSigningPolicy=\"Ignore\""
  1148. echo " OemPnPDriversPath=\"Drivers\viostor;Drivers\NetKVM;Drivers\sata\""
  1149. echo " NoWaitAfterTextMode=1"
  1150. echo " NoWaitAfterGUIMode=1"
  1151. echo " FileSystem-ConvertNTFS"
  1152. echo " ExtendOemPartition=0"
  1153. echo " Hibernation=\"No\""
  1154. echo ""
  1155. echo "[GuiUnattended]"
  1156. echo " OEMSkipRegional=1"
  1157. echo " OemSkipWelcome=1"
  1158. echo " AdminPassword=$password"
  1159. echo " TimeZone=0"
  1160. echo " AutoLogon=Yes"
  1161. echo " AutoLogonCount=65432"
  1162. echo ""
  1163. echo "[UserData]"
  1164. echo " FullName=\"$username\""
  1165. echo " ComputerName=\"*\""
  1166. echo " OrgName=\"Windows for Docker\""
  1167. echo " ProductKey=$key"
  1168. echo ""
  1169. echo "[Identification]"
  1170. echo " JoinWorkgroup = WORKGROUP"
  1171. echo ""
  1172. echo "[Display]"
  1173. echo " BitsPerPel=32"
  1174. echo " XResolution=$WIDTH"
  1175. echo " YResolution=$HEIGHT"
  1176. echo ""
  1177. echo "[Networking]"
  1178. echo " InstallDefaultComponents=Yes"
  1179. echo ""
  1180. echo "[Branding]"
  1181. echo " BrandIEUsingUnattended=Yes"
  1182. echo ""
  1183. echo "[URL]"
  1184. echo " Home_Page = http://www.google.com"
  1185. echo " Search_Page = http://www.google.com"
  1186. echo ""
  1187. echo "[TerminalServices]"
  1188. echo " AllowConnections=1"
  1189. echo ""
  1190. } | unix2dos > "$target/WINNT.SIF"
  1191. if [[ "$driver" == "2k3" ]]; then
  1192. { echo "[Components]"
  1193. echo " TerminalServer=On"
  1194. echo ""
  1195. echo "[LicenseFilePrintData]"
  1196. echo " AutoMode=PerServer"
  1197. echo " AutoUsers=5"
  1198. echo ""
  1199. } | unix2dos >> "$target/WINNT.SIF"
  1200. fi
  1201. { echo "Windows Registry Editor Version 5.00"
  1202. echo ""
  1203. echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security]"
  1204. echo "\"FirstRunDisabled\"=dword:00000001"
  1205. echo "\"UpdatesDisableNotify\"=dword:00000001"
  1206. echo "\"FirewallDisableNotify\"=dword:00000001"
  1207. echo "\"AntiVirusDisableNotify\"=dword:00000001"
  1208. echo ""
  1209. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wscsvc]"
  1210. echo "\"Start\"=dword:00000004"
  1211. echo ""
  1212. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List]"
  1213. echo "\"3389:TCP\"=\"3389:TCP:*:Enabled:@xpsp2res.dll,-22009\""
  1214. echo ""
  1215. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]"
  1216. echo "\"LimitBlankPasswordUse\"=dword:00000000"
  1217. echo ""
  1218. echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Tour]"
  1219. echo "\"RunCount\"=dword:00000000"
  1220. echo ""
  1221. echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]"
  1222. echo "\"HideFileExt\"=dword:00000000"
  1223. echo ""
  1224. echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]"
  1225. echo "\"DefaultUserName\"=\"$username\""
  1226. echo "\"DefaultDomainName\"=\"Dockur\""
  1227. echo "\"AltDefaultUserName\"=\"$username\""
  1228. echo "\"AltDefaultDomainName\"=\"Dockur\""
  1229. echo "\"AutoAdminLogon\"=\"1\""
  1230. echo ""
  1231. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{23A77BF7-ED96-40EC-AF06-9B1F4867732A}\0000]"
  1232. echo "\"DefaultSettings.BitsPerPel\"=dword:00000020"
  1233. echo "\"DefaultSettings.XResolution\"=dword:00000$XHEX"
  1234. echo "\"DefaultSettings.YResolution\"=dword:00000$YHEX"
  1235. echo ""
  1236. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Control\VIDEO\{23A77BF7-ED96-40EC-AF06-9B1F4867732A}\0000]"
  1237. echo "\"DefaultSettings.BitsPerPel\"=dword:00000020"
  1238. echo "\"DefaultSettings.XResolution\"=dword:00000$XHEX"
  1239. echo "\"DefaultSettings.YResolution\"=dword:00000$YHEX"
  1240. echo ""
  1241. echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]"
  1242. echo "\"ScreenSaver\"=\"reg add \\\"HKCU\\\\Control Panel\\\\Desktop\\\" /f /v \\\"SCRNSAVE.EXE\\\" /t REG_SZ /d \\\"off\\\"\""
  1243. echo "\"ScreenSaverOff\"=\"reg add \\\"HKCU\\\\Control Panel\\\\Desktop\\\" /f /v \\\"ScreenSaveActive\\\" /t REG_SZ /d \\\"0\\\"\""
  1244. echo "$oem"
  1245. echo ""
  1246. } | unix2dos > "$dir/\$OEM\$/install.reg"
  1247. if [[ "$driver" == "2k3" ]]; then
  1248. { echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\srvWiz]"
  1249. echo "@=dword:00000000"
  1250. echo ""
  1251. echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ServerOOBE\SecurityOOBE]"
  1252. echo "\"DontLaunchSecurityOOBE\"=dword:00000000"
  1253. echo ""
  1254. } | unix2dos >> "$dir/\$OEM\$/install.reg"
  1255. fi
  1256. { echo "Set WshShell = WScript.CreateObject(\"WScript.Shell\")"
  1257. echo "Set WshNetwork = WScript.CreateObject(\"WScript.Network\")"
  1258. echo "Set Domain = GetObject(\"WinNT://\" & WshNetwork.ComputerName)"
  1259. echo ""
  1260. echo "Function DecodeSID(binSID)"
  1261. echo " ReDim o(LenB(binSID))"
  1262. echo ""
  1263. echo " For i = 1 To LenB(binSID)"
  1264. echo " o(i-1) = AscB(MidB(binSID, i, 1))"
  1265. echo " Next"
  1266. echo ""
  1267. echo " sid = \"S-\" & CStr(o(0)) & \"-\" & OctetArrayToString _"
  1268. echo " (Array(o(2), o(3), o(4), o(5), o(6), o(7)))"
  1269. echo " For i = 8 To (4 * o(1) + 4) Step 4"
  1270. echo " sid = sid & \"-\" & OctetArrayToString _"
  1271. echo " (Array(o(i+3), o(i+2), o(i+1), o(i)))"
  1272. echo " Next"
  1273. echo ""
  1274. echo " DecodeSID = sid"
  1275. echo "End Function"
  1276. echo ""
  1277. echo "Function OctetArrayToString(arr)"
  1278. echo " v = 0"
  1279. echo " For i = 0 To UBound(arr)"
  1280. echo " v = v * 256 + arr(i)"
  1281. echo " Next"
  1282. echo ""
  1283. echo " OctetArrayToString = CStr(v)"
  1284. echo "End Function"
  1285. echo ""
  1286. echo "For Each DomainItem in Domain"
  1287. echo " If DomainItem.Class = \"User\" Then"
  1288. echo " sid = DecodeSID(DomainItem.Get(\"objectSID\"))"
  1289. echo " If Left(sid, 9) = \"S-1-5-21-\" And Right(sid, 4) = \"-500\" Then"
  1290. echo " LocalAdminADsPath = DomainItem.ADsPath"
  1291. echo " Exit For"
  1292. echo " End If"
  1293. echo " End If"
  1294. echo "Next"
  1295. echo ""
  1296. echo "Call Domain.MoveHere(LocalAdminADsPath, \"$username\")"
  1297. echo ""
  1298. } | unix2dos > "$dir/\$OEM\$/admin.vbs"
  1299. { echo "[COMMANDS]"
  1300. echo "\"REGEDIT /s install.reg\""
  1301. echo "\"Wscript admin.vbs\""
  1302. echo ""
  1303. } | unix2dos > "$dir/\$OEM\$/cmdlines.txt"
  1304. return 0
  1305. }
  1306. prepare2k3() {
  1307. local iso="$1"
  1308. local dir="$2"
  1309. local desc="$3"
  1310. local driver="2k3"
  1311. local arch key
  1312. [ -d "$dir/AMD64" ] && arch="amd64" || arch="x86"
  1313. if [[ "${arch,,}" == "x86" ]]; then
  1314. # Windows Server 2003 Standard x86 generic key (no activation, trial-only)
  1315. # This is not a pirated key, it comes from the official MS documentation.
  1316. key="QKDCQ-TP2JM-G4MDG-VR6F2-P9C48"
  1317. else
  1318. # Windows Server 2003 Standard x64 generic key (no activation, trial-only)
  1319. # This is not a pirated key, it comes from the official MS documentation.
  1320. key="P4WJG-WK3W7-3HM8W-RWHCK-8JTRY"
  1321. fi
  1322. prepareInstall "$iso" "$dir" "$desc" "$arch" "$key" "$driver" || return 1
  1323. return 0
  1324. }
  1325. prepareXP() {
  1326. local iso="$1"
  1327. local dir="$2"
  1328. local desc="$3"
  1329. local driver="xp"
  1330. local arch key
  1331. [ -d "$dir/AMD64" ] && arch="amd64" || arch="x86"
  1332. if [[ "${arch,,}" == "x86" ]]; then
  1333. # Windows XP Professional x86 generic key (no activation, trial-only)
  1334. # This is not a pirated key, it comes from the official MS documentation.
  1335. key="DR8GV-C8V6J-BYXHG-7PYJR-DB66Y"
  1336. else
  1337. # Windows XP Professional x64 generic key (no activation, trial-only)
  1338. # This is not a pirated key, it comes from the official MS documentation.
  1339. key="B2RBK-7KPT9-4JP6X-QQFWM-PJD6G"
  1340. fi
  1341. prepareInstall "$iso" "$dir" "$desc" "$arch" "$key" "$driver" || return 1
  1342. return 0
  1343. }
  1344. prepareLegacy() {
  1345. local iso="$1"
  1346. local dir="$2"
  1347. local desc="$3"
  1348. ETFS="boot.img"
  1349. [ -f "$dir/$ETFS" ] && [ -s "$dir/$ETFS" ] && return 0
  1350. rm -f "$dir/$ETFS"
  1351. local len offset
  1352. len=$(isoinfo -d -i "$iso" | grep "Nsect " | grep -o "[^ ]*$")
  1353. offset=$(isoinfo -d -i "$iso" | grep "Bootoff " | grep -o "[^ ]*$")
  1354. if ! dd "if=$iso" "of=$dir/$ETFS" bs=2048 "count=$len" "skip=$offset" status=none; then
  1355. error "Failed to extract boot image from $desc ISO!" && return 1
  1356. fi
  1357. [ -f "$dir/$ETFS" ] && [ -s "$dir/$ETFS" ] && return 0
  1358. error "Failed to locate file \"$ETFS\" in $desc ISO image!"
  1359. return 1
  1360. }
  1361. detectLegacy() {
  1362. local dir="$1"
  1363. local find find2
  1364. find=$(find "$dir" -maxdepth 1 -type d -iname win95 | head -n 1)
  1365. [ -n "$find" ] && DETECTED="win95" && return 0
  1366. find=$(find "$dir" -maxdepth 1 -type d -iname win98 | head -n 1)
  1367. [ -n "$find" ] && DETECTED="win98" && return 0
  1368. find=$(find "$dir" -maxdepth 1 -type d -iname win9x | head -n 1)
  1369. [ -n "$find" ] && DETECTED="win9x" && return 0
  1370. find=$(find "$dir" -maxdepth 1 -type f -iname cdrom_nt.5 | head -n 1)
  1371. [ -n "$find" ] && DETECTED="win2k" && return 0
  1372. find=$(find "$dir" -maxdepth 1 -type d -iname win51 | head -n 1)
  1373. find2=$(find "$dir" -maxdepth 1 -type f -iname setupxp.htm | head -n 1)
  1374. if [ -n "$find" ] || [ -n "$find2" ] || [ -f "$dir/WIN51AP" ] || [ -f "$dir/WIN51IC" ]; then
  1375. [ -d "$dir/AMD64" ] && DETECTED="winxpx64" && return 0
  1376. DETECTED="winxpx86" && return 0
  1377. fi
  1378. if [ -f "$dir/WIN51IA" ] || [ -f "$dir/WIN51IB" ] || [ -f "$dir/WIN51ID" ] || [ -f "$dir/WIN51IL" ] || [ -f "$dir/WIN51IS" ]; then
  1379. DETECTED="win2003r2" && return 0
  1380. fi
  1381. if [ -f "$dir/WIN51AA" ] || [ -f "$dir/WIN51AD" ] || [ -f "$dir/WIN51AS" ] || [ -f "$dir/WIN51MA" ] || [ -f "$dir/WIN51MD" ]; then
  1382. DETECTED="win2003r2" && return 0
  1383. fi
  1384. return 1
  1385. }
  1386. skipVersion() {
  1387. local id="$1"
  1388. case "${id,,}" in
  1389. "win9"* | "winxp"* | "win2k"* | "win2003"* )
  1390. return 0 ;;
  1391. esac
  1392. return 1
  1393. }
  1394. setMachine() {
  1395. local id="$1"
  1396. local iso="$2"
  1397. local dir="$3"
  1398. local desc="$4"
  1399. case "${id,,}" in
  1400. "win9"* )
  1401. ETFS="[BOOT]/Boot-1.44M.img" ;;
  1402. "win2k"* )
  1403. ETFS="[BOOT]/Boot-NoEmul.img" ;;
  1404. "winxp"* )
  1405. if ! prepareXP "$iso" "$dir" "$desc"; then
  1406. error "Failed to prepare $desc ISO!" && return 1
  1407. fi ;;
  1408. "win2003"* )
  1409. if ! prepare2k3 "$iso" "$dir" "$desc"; then
  1410. error "Failed to prepare $desc ISO!" && return 1
  1411. fi ;;
  1412. esac
  1413. case "${id,,}" in
  1414. "win9"* | "win2k"* )
  1415. DISK_TYPE="auto"
  1416. MACHINE="pc-i440fx-2.4"
  1417. BOOT_MODE="windows_legacy" ;;
  1418. "winxp"* | "win2003"* )
  1419. DISK_TYPE="blk"
  1420. BOOT_MODE="windows_legacy" ;;
  1421. "winvista"* | "win7"* | "win2008"* )
  1422. BOOT_MODE="windows_legacy" ;;
  1423. esac
  1424. case "${id,,}" in
  1425. "winxp"* | "win2003"* | "winvistax86"* | "win7x86"* | "win2008r2x86"* )
  1426. # Prevent bluescreen if 64 bit PCI hole size is >2G.
  1427. ARGS="-global q35-pcihost.x-pci-hole64-fix=false" ;;
  1428. esac
  1429. return 0
  1430. }
  1431. return 0