define.sh 51 KB

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