define.sh 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. #!/usr/bin/env bash
  2. set -Eeuo pipefail
  3. : "${VERIFY:=""}"
  4. : "${MANUAL:=""}"
  5. : "${REMOVE:=""}"
  6. : "${VERSION:=""}"
  7. : "${DETECTED:=""}"
  8. MIRRORS=5
  9. PLATFORM="x64"
  10. parseVersion() {
  11. VERSION="${VERSION/\//}"
  12. if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
  13. VERSION="${VERSION:1:-1}"
  14. fi
  15. [ -z "$VERSION" ] && VERSION="win11"
  16. case "${VERSION,,}" in
  17. "11" | "11p" | "win11" | "win11p" | "windows11" | "windows 11" )
  18. VERSION="win11${PLATFORM,,}"
  19. ;;
  20. "11e" | "win11e" | "windows11e" | "windows 11e" )
  21. VERSION="win11${PLATFORM,,}-enterprise-eval"
  22. ;;
  23. "10" | "10p" | "win10" | "win10p" | "windows10" | "windows 10" )
  24. VERSION="win10${PLATFORM,,}"
  25. ;;
  26. "10e" | "win10e" | "windows10e" | "windows 10e" )
  27. VERSION="win10${PLATFORM,,}-enterprise-eval"
  28. ;;
  29. "8" | "8p" | "81" | "81p" | "8.1" | "win8" | "win8p" | "win81" | "win81p" | "windows 8" )
  30. VERSION="win81${PLATFORM,,}"
  31. ;;
  32. "8e" | "81e" | "8.1e" | "win8e" | "win81e" | "windows 8e" )
  33. VERSION="win81${PLATFORM,,}-enterprise-eval"
  34. ;;
  35. "7" | "7e" | "win7" | "win7e" | "windows7" | "windows 7" )
  36. VERSION="win7${PLATFORM,,}"
  37. [ -z "$DETECTED" ] && DETECTED="win7${PLATFORM,,}-enterprise"
  38. ;;
  39. "7u" | "win7u" | "windows7u" | "windows 7u" )
  40. VERSION="win7${PLATFORM,,}-ultimate"
  41. ;;
  42. "vista" | "winvista" | "windowsvista" | "windows vista" )
  43. VERSION="winvista${PLATFORM,,}"
  44. [ -z "$DETECTED" ] && DETECTED="winvista${PLATFORM,,}-enterprise"
  45. ;;
  46. "vistu" | "winvistu" | "windowsvistu" | "windows vistu" )
  47. VERSION="winvista${PLATFORM,,}-ultimate"
  48. ;;
  49. "xp" | "xp32" | "xpx86" | "winxp" | "winxp86" | "windowsxp" | "windows xp" )
  50. VERSION="winxpx86"
  51. ;;
  52. "xp64" | "xpx64" | "winxp64" | "winxpx64" | "windowsxp64" | "windowsxpx64" )
  53. VERSION="winxp${PLATFORM,,}"
  54. ;;
  55. "22" | "2022" | "win22" | "win2022" | "windows2022" | "windows 2022" )
  56. VERSION="win2022-eval"
  57. ;;
  58. "19" | "2019" | "win19" | "win2019" | "windows2019" | "windows 2019" )
  59. VERSION="win2019-eval"
  60. ;;
  61. "16" | "2016" | "win16" | "win2016" | "windows2016" | "windows 2016" )
  62. VERSION="win2016-eval"
  63. ;;
  64. "2012" | "2012r2" | "win2012" | "win2012r2" | "windows2012" | "windows 2012" )
  65. VERSION="win2012r2-eval"
  66. ;;
  67. "2008" | "2008r2" | "win2008" | "win2008r2" | "windows2008" | "windows 2008" )
  68. VERSION="win2008r2"
  69. ;;
  70. "core11" | "core 11" )
  71. VERSION="core11"
  72. [ -z "$DETECTED" ] && DETECTED="win11${PLATFORM,,}"
  73. ;;
  74. "tiny11" | "tiny 11" )
  75. VERSION="tiny11"
  76. [ -z "$DETECTED" ] && DETECTED="win11${PLATFORM,,}"
  77. ;;
  78. "tiny10" | "tiny 10" )
  79. VERSION="tiny10"
  80. [ -z "$DETECTED" ] && DETECTED="win10${PLATFORM,,}-ltsc"
  81. ;;
  82. "iot11" | "11iot" | "win11-iot" | "win11${PLATFORM,,}-iot" | "win11${PLATFORM,,}-enterprise-iot-eval" )
  83. VERSION="win11${PLATFORM,,}-enterprise-iot-eval"
  84. [ -z "$DETECTED" ] && DETECTED="win11${PLATFORM,,}-iot"
  85. ;;
  86. "iot10" | "10iot" | "win10-iot" | "win10${PLATFORM,,}-iot" | "win10${PLATFORM,,}-enterprise-iot-eval" )
  87. VERSION="win10${PLATFORM,,}-enterprise-iot-eval"
  88. [ -z "$DETECTED" ] && DETECTED="win10${PLATFORM,,}-iot"
  89. ;;
  90. "ltsc10" | "10ltsc" | "win10-ltsc" | "win10${PLATFORM,,}-ltsc" | "win10${PLATFORM,,}-enterprise-ltsc-eval" )
  91. VERSION="win10${PLATFORM,,}-enterprise-ltsc-eval"
  92. [ -z "$DETECTED" ] && DETECTED="win10${PLATFORM,,}-ltsc"
  93. ;;
  94. esac
  95. return 0
  96. }
  97. printVersion() {
  98. local id="$1"
  99. local desc="$2"
  100. case "${id,,}" in
  101. "tiny11"* ) desc="Tiny 11" ;;
  102. "tiny10"* ) desc="Tiny 10" ;;
  103. "core11"* ) desc="Core 11" ;;
  104. "win7"* ) desc="Windows 7" ;;
  105. "win8"* ) desc="Windows 8" ;;
  106. "win10"* ) desc="Windows 10" ;;
  107. "win11"* ) desc="Windows 11" ;;
  108. "winxp"* ) desc="Windows XP" ;;
  109. "winvista"* ) desc="Windows Vista" ;;
  110. "win2025"* ) desc="Windows Server 2025" ;;
  111. "win2022"* ) desc="Windows Server 2022" ;;
  112. "win2019"* ) desc="Windows Server 2019" ;;
  113. "win2016"* ) desc="Windows Server 2016" ;;
  114. "win2012"* ) desc="Windows Server 2012" ;;
  115. "win2008"* ) desc="Windows Server 2008" ;;
  116. esac
  117. if [ -z "$desc" ]; then
  118. desc="Windows"
  119. [[ "${PLATFORM,,}" != "x64" ]] && desc="$desc for ${PLATFORM}"
  120. fi
  121. echo "$desc"
  122. return 0
  123. }
  124. printEdition() {
  125. local id="$1"
  126. local desc="$2"
  127. local result=""
  128. local edition=""
  129. result=$(printVersion "$id" "x")
  130. [[ "$result" == "x" ]] && echo "$desc" && return 0
  131. case "${id,,}" in
  132. *"-iot" )
  133. edition="IoT"
  134. ;;
  135. *"-ltsc" )
  136. edition="LTSC"
  137. ;;
  138. *"-home" )
  139. edition="Home"
  140. ;;
  141. *"-starter" )
  142. edition="Starter"
  143. ;;
  144. *"-ultimate" )
  145. edition="Ultimate"
  146. ;;
  147. *"-enterprise" )
  148. edition="Enterprise"
  149. ;;
  150. *"-education" )
  151. edition="Education"
  152. ;;
  153. *"-enterprise-eval" )
  154. edition="Enterprise (Evaluation)"
  155. ;;
  156. "win7"* )
  157. edition="Professional"
  158. ;;
  159. "win8"* | "win10"* | "win11"* )
  160. edition="Pro"
  161. ;;
  162. "winxp"* )
  163. edition="Professional"
  164. ;;
  165. "winvista"* )
  166. edition="Business"
  167. ;;
  168. "win2025"* | "win2022"* | "win2019"* | "win2016"* | "win2012"* | "win2008"* )
  169. edition="Standard"
  170. ;;
  171. esac
  172. [ -n "$edition" ] && result="$result $edition"
  173. echo "$result"
  174. return 0
  175. }
  176. fromFile() {
  177. local id=""
  178. local desc="$1"
  179. local file="${1,,}"
  180. local arch="${PLATFORM,,}"
  181. case "${file/ /_}" in
  182. *"_x64_"* | *"_x64."*)
  183. arch="x64"
  184. ;;
  185. *"_x86_"* | *"_x86."*)
  186. arch="x86"
  187. ;;
  188. *"_arm64_"* | *"_arm64."*)
  189. arch="arm64"
  190. ;;
  191. esac
  192. case "${file/ /_}" in
  193. "win7"* | "win_7"* | *"windows7"* | *"windows_7"* )
  194. id="win7${arch}"
  195. ;;
  196. "win8"* | "win_8"* | *"windows8"* | *"windows_8"* )
  197. id="win81${arch}"
  198. ;;
  199. "win10"*| "win_10"* | *"windows10"* | *"windows_10"* )
  200. id="win10${arch}"
  201. ;;
  202. "win11"* | "win_11"* | *"windows11"* | *"windows_11"* )
  203. id="win11${arch}"
  204. ;;
  205. *"winxp"* | *"win_xp"* | *"windowsxp"* | *"windows_xp"* )
  206. id="winxpx86"
  207. ;;
  208. *"winvista"* | *"win_vista"* | *"windowsvista"* | *"windows_vista"* )
  209. id="winvista${arch}"
  210. ;;
  211. "tiny11core"* | "tiny11_core"* | "tiny_11_core"* )
  212. id="core11"
  213. ;;
  214. "tiny11"* | "tiny_11"* )
  215. id="tiny11"
  216. ;;
  217. "tiny10"* | "tiny_10"* )
  218. id="tiny10"
  219. ;;
  220. *"server2025"* | *"server_2025"* )
  221. id="win2025"
  222. ;;
  223. *"server2022"* | *"server_2022"* )
  224. id="win2022"
  225. ;;
  226. *"server2019"* | *"server_2019"* )
  227. id="win2019"
  228. ;;
  229. *"server2016"* | *"server_2016"* )
  230. id="win2016"
  231. ;;
  232. *"server2012"* | *"server_2012"* )
  233. id="win2012r2"
  234. ;;
  235. *"server2008"* | *"server_2008"* )
  236. id="win2008r2"
  237. ;;
  238. esac
  239. if [ -n "$id" ]; then
  240. desc=$(printVersion "$id" "$desc")
  241. fi
  242. echo "$desc"
  243. return 0
  244. }
  245. fromName() {
  246. local id=""
  247. local name="$1"
  248. local arch="$2"
  249. case "${name,,}" in
  250. *"server 2025"* ) id="win2025" ;;
  251. *"server 2022"* ) id="win2022" ;;
  252. *"server 2019"* ) id="win2019" ;;
  253. *"server 2016"* ) id="win2016" ;;
  254. *"server 2012"* ) id="win2012r2" ;;
  255. *"server 2008"* ) id="win2008r2" ;;
  256. *"windows 7"* ) id="win7${arch}" ;;
  257. *"windows 8"* ) id="win81${arch}" ;;
  258. *"windows 10"* ) id="win10${arch}" ;;
  259. *"windows 11"* ) id="win11${arch}" ;;
  260. *"windows vista"* ) id="winvista${arch}" ;;
  261. esac
  262. echo "$id"
  263. return 0
  264. }
  265. getVersion() {
  266. local id
  267. local name="$1"
  268. local arch="$2"
  269. id=$(fromName "$name" "$arch")
  270. case "${id,,}" in
  271. "win7"* | "winvista"* )
  272. case "${name,,}" in
  273. *" home"* ) id="$id-home" ;;
  274. *" starter"* ) id="$id-starter" ;;
  275. *" ultimate"* ) id="$id-ultimate" ;;
  276. *" enterprise"* ) id="$id-enterprise" ;;
  277. esac
  278. ;;
  279. "win8"* )
  280. case "${name,,}" in
  281. *" enterprise evaluation"* ) id="$id-enterprise-eval" ;;
  282. *" enterprise"* ) id="$id-enterprise" ;;
  283. esac
  284. ;;
  285. "win10"* )
  286. case "${name,,}" in
  287. *" iot"* ) id="$id-iot" ;;
  288. *" ltsc"* ) id="$id-ltsc" ;;
  289. *" home"* ) id="$id-home" ;;
  290. *" education"* ) id="$id-education" ;;
  291. *" enterprise evaluation"* ) id="$id-enterprise-eval" ;;
  292. *" enterprise"* ) id="$id-enterprise" ;;
  293. esac
  294. ;;
  295. "win11"* )
  296. case "${name,,}" in
  297. *" iot"* ) id="$id-iot" ;;
  298. *" home"* ) id="$id-home" ;;
  299. *" education"* ) id="$id-education" ;;
  300. *" enterprise evaluation"* ) id="$id-enterprise-eval" ;;
  301. *" enterprise"* ) id="$id-enterprise" ;;
  302. esac
  303. ;;
  304. "win2025"* | "win2022"* | "win2019"* | "win2016"* | "win2012"* | "win2008"* )
  305. case "${name,,}" in
  306. *" evaluation"* ) id="$id-eval" ;;
  307. esac
  308. ;;
  309. esac
  310. echo "$id"
  311. return 0
  312. }
  313. switchEdition() {
  314. local id="$1"
  315. case "${id,,}" in
  316. "win11${PLATFORM,,}-enterprise-eval" )
  317. DETECTED="win11${PLATFORM,,}-enterprise"
  318. ;;
  319. "win10${PLATFORM,,}-enterprise-eval" )
  320. DETECTED="win10${PLATFORM,,}-enterprise"
  321. ;;
  322. "win81${PLATFORM,,}-enterprise-eval" )
  323. DETECTED="win81${PLATFORM,,}-enterprise"
  324. ;;
  325. "win2022-eval" ) DETECTED="win2022" ;;
  326. "win2019-eval" ) DETECTED="win2019" ;;
  327. "win2016-eval" ) DETECTED="win2016" ;;
  328. "win2012r2-eval" ) DETECTED="win2012r2" ;;
  329. "win2008r2-eval" ) DETECTED="win2008r2" ;;
  330. esac
  331. return 0
  332. }
  333. getCatalog() {
  334. local id="$1"
  335. local ret="$2"
  336. local url=""
  337. local name=""
  338. local edition=""
  339. case "${id,,}" in
  340. "win11${PLATFORM,,}" )
  341. edition="Professional"
  342. name="Windows 11 Pro"
  343. url="https://go.microsoft.com/fwlink?linkid=2156292"
  344. ;;
  345. "win10${PLATFORM,,}" )
  346. edition="Professional"
  347. name="Windows 10 Pro"
  348. url="https://go.microsoft.com/fwlink/?LinkId=841361"
  349. ;;
  350. "win11${PLATFORM,,}-enterprise" | "win11${PLATFORM,,}-enterprise-eval")
  351. edition="Enterprise"
  352. name="Windows 11 Enterprise"
  353. url="https://go.microsoft.com/fwlink?linkid=2156292"
  354. ;;
  355. "win10${PLATFORM,,}-enterprise" | "win10${PLATFORM,,}-enterprise-eval" )
  356. edition="Enterprise"
  357. name="Windows 10 Enterprise"
  358. url="https://go.microsoft.com/fwlink/?LinkId=841361"
  359. ;;
  360. esac
  361. case "${ret,,}" in
  362. "url" ) echo "$url" ;;
  363. "name" ) echo "$name" ;;
  364. "edition" ) echo "$edition" ;;
  365. *) echo "";;
  366. esac
  367. return 0
  368. }
  369. getMido() {
  370. local id="$1"
  371. local ret="$2"
  372. local sum=""
  373. local size=""
  374. case "${id,,}" in
  375. "win11${PLATFORM,,}" )
  376. size=6812706816
  377. sum="36de5ecb7a0daa58dce68c03b9465a543ed0f5498aa8ae60ab45fb7c8c4ae402"
  378. ;;
  379. "win11${PLATFORM,,}-enterprise-eval" )
  380. size=6209064960
  381. sum="c8dbc96b61d04c8b01faf6ce0794fdf33965c7b350eaa3eb1e6697019902945c"
  382. ;;
  383. "win10${PLATFORM,,}" )
  384. size=6140975104
  385. sum="a6f470ca6d331eb353b815c043e327a347f594f37ff525f17764738fe812852e"
  386. ;;
  387. "win10${PLATFORM,,}-enterprise-eval" )
  388. size=5550497792
  389. sum="ef7312733a9f5d7d51cfa04ac497671995674ca5e1058d5164d6028f0938d668"
  390. ;;
  391. "win10${PLATFORM,,}-enterprise-ltsc-eval" )
  392. size=4898582528
  393. sum="e4ab2e3535be5748252a8d5d57539a6e59be8d6726345ee10e7afd2cb89fefb5"
  394. ;;
  395. "win81${PLATFORM,,}" )
  396. size=4320526336
  397. sum="d8333cf427eb3318ff6ab755eb1dd9d433f0e2ae43745312c1cd23e83ca1ce51"
  398. ;;
  399. "win81${PLATFORM,,}-enterprise-eval" )
  400. size=3961473024
  401. sum="2dedd44c45646c74efc5a028f65336027e14a56f76686a4631cf94ffe37c72f2"
  402. ;;
  403. "win2022-eval" )
  404. size=5044094976
  405. sum="3e4fa6d8507b554856fc9ca6079cc402df11a8b79344871669f0251535255325"
  406. ;;
  407. "win2019-eval" )
  408. size=5652088832
  409. sum="6dae072e7f78f4ccab74a45341de0d6e2d45c39be25f1f5920a2ab4f51d7bcbb"
  410. ;;
  411. "win2016-eval" )
  412. size=6972221440
  413. sum="1ce702a578a3cb1ac3d14873980838590f06d5b7101c5daaccbac9d73f1fb50f"
  414. ;;
  415. "win2012r2-eval" )
  416. size=4542291968
  417. sum="6612b5b1f53e845aacdf96e974bb119a3d9b4dcb5b82e65804ab7e534dc7b4d5"
  418. ;;
  419. "win2008r2" )
  420. size=3166840832
  421. sum="30832ad76ccfa4ce48ccb936edefe02079d42fb1da32201bf9e3a880c8ed6312"
  422. ;;
  423. esac
  424. case "${ret,,}" in
  425. "sum" ) echo "$sum" ;;
  426. "size" ) echo "$size" ;;
  427. *) echo "";;
  428. esac
  429. return 1
  430. }
  431. getLink1() {
  432. # Fallbacks for users who cannot connect to the Microsoft servers
  433. local id="$1"
  434. local ret="$2"
  435. local url=""
  436. local sum=""
  437. local size=""
  438. local host="https://dl.bobpony.com/windows"
  439. case "${id,,}" in
  440. "win11${PLATFORM,,}" )
  441. size=5946128384
  442. sum="5bb1459034f50766ee480d895d751af73a4af30814240ae32ebc5633546a5af7"
  443. url="$host/11/en-us_windows_11_23h2_${PLATFORM,,}.iso"
  444. ;;
  445. "win10${PLATFORM,,}" )
  446. size=4957009920
  447. sum="6673e2ab6c6939a74eceff2c2bb4d36feb94ff8a6f71700adef0f0b998fdcaca"
  448. url="$host/10/en-us_windows_10_22h2_${PLATFORM,,}.iso"
  449. ;;
  450. "win10${PLATFORM,,}-iot" | "win10${PLATFORM,,}-enterprise-iot-eval" )
  451. size=4851668992
  452. sum="a0334f31ea7a3e6932b9ad7206608248f0bd40698bfb8fc65f14fc5e4976c160"
  453. url="$host/10/en-us_windows_10_iot_enterprise_ltsc_2021_${PLATFORM,,}_dvd_257ad90f.iso"
  454. ;;
  455. "win10${PLATFORM,,}-ltsc" | "win10${PLATFORM,,}-enterprise-ltsc-eval" )
  456. size=4899461120
  457. sum="c90a6df8997bf49e56b9673982f3e80745058723a707aef8f22998ae6479597d"
  458. url="$host/10/en-us_windows_10_enterprise_ltsc_2021_${PLATFORM,,}_dvd_d289cf96.iso"
  459. ;;
  460. "win81${PLATFORM,,}" )
  461. size=4320526336
  462. sum="d8333cf427eb3318ff6ab755eb1dd9d433f0e2ae43745312c1cd23e83ca1ce51"
  463. url="$host/8.x/8.1/en_windows_8.1_with_update_${PLATFORM,,}_dvd_6051480.iso"
  464. ;;
  465. "win2022" | "win2022-eval" )
  466. size=5365624832
  467. sum="c3c57bb2cf723973a7dcfb1a21e97dfa035753a7f111e348ad918bb64b3114db"
  468. url="$host/server/2022/en-us_windows_server_2022_updated_jan_2024_${PLATFORM,,}_dvd_2b7a0c9f.iso"
  469. ;;
  470. "win2019" | "win2019-eval" )
  471. size=5575774208
  472. sum="0067afe7fdc4e61f677bd8c35a209082aa917df9c117527fc4b2b52a447e89bb"
  473. url="$host/server/2019/en-us_windows_server_2019_updated_aug_2021_${PLATFORM,,}_dvd_a6431a28.iso"
  474. ;;
  475. "win2016" | "win2016-eval" )
  476. size=6006587392
  477. sum="af06e5483c786c023123e325cea4775050324d9e1366f46850b515ae43f764be"
  478. url="$host/server/2016/en_windows_server_2016_updated_feb_2018_${PLATFORM,,}_dvd_11636692.iso"
  479. ;;
  480. "win2012r2" | "win2012r2-eval" )
  481. size=5397889024
  482. sum="f351e89eb88a96af4626ceb3450248b8573e3ed5924a4e19ea891e6003b62e4e"
  483. url="$host/server/2012r2/en_windows_server_2012_r2_with_update_${PLATFORM,,}_dvd_6052708-004.iso"
  484. ;;
  485. "win2008r2" | "win2008r2-eval" )
  486. size=3166584832
  487. sum="dfd9890881b7e832a927c38310fb415b7ea62ac5a896671f2ce2a111998f0df8"
  488. url="$host/server/2008r2/en_windows_server_2008_r2_with_sp1_${PLATFORM,,}_dvd_617601-018.iso"
  489. ;;
  490. "win7${PLATFORM,,}" | "win7${PLATFORM,,}-enterprise" )
  491. size=3182604288
  492. sum="ee69f3e9b86ff973f632db8e01700c5724ef78420b175d25bae6ead90f6805a7"
  493. url="$host/7/en_windows_7_enterprise_with_sp1_${PLATFORM,,}_dvd_u_677651.iso"
  494. ;;
  495. "win7${PLATFORM,,}-ultimate" )
  496. size=3320836096
  497. sum="0b738b55a5ea388ad016535a5c8234daf2e5715a0638488ddd8a228a836055a1"
  498. url="$host/7/en_windows_7_with_sp1_${PLATFORM,,}.iso"
  499. ;;
  500. "win7x86" | "win7x86-enterprise" )
  501. size=2434502656
  502. sum="8bdd46ff8cb8b8de9c4aba02706629c8983c45e87da110e64e13be17c8434dad"
  503. url="$host/7/en_windows_7_enterprise_with_sp1_x86_dvd_u_677710.iso"
  504. ;;
  505. "win7x86-ultimate" )
  506. size=2564411392
  507. sum="99f3369c90160816be07093dbb0ac053e0a84e52d6ed1395c92ae208ccdf67e5"
  508. url="$host/7/en_windows_7_with_sp1_x86.iso"
  509. ;;
  510. "winvista${PLATFORM,,}-ultimate" )
  511. size=3861460992
  512. sum="edf9f947c5791469fd7d2d40a5dcce663efa754f91847aa1d28ed7f585675b78"
  513. url="$host/vista/en_windows_vista_sp2_${PLATFORM,,}_dvd_342267.iso"
  514. ;;
  515. "winvistax86-ultimate" )
  516. size=3243413504
  517. sum="9c36fed4255bd05a8506b2da88f9aad73643395e155e609398aacd2b5276289c"
  518. url="$host/vista/en_windows_vista_with_sp2_x86_dvd_342266.iso"
  519. ;;
  520. "winxpx86" )
  521. size=617756672
  522. sum="62b6c91563bad6cd12a352aa018627c314cfc5162d8e9f8af0756a642e602a46"
  523. url="$host/xp/professional/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
  524. ;;
  525. "winxpx64" )
  526. size=614166528
  527. sum="8fac68e1e56c64ad9a2aa0ad464560282e67fa4f4dd51d09a66f4e548eb0f2d6"
  528. url="$host/xp/professional/en_win_xp_pro_${PLATFORM,,}_vl.iso"
  529. ;;
  530. esac
  531. case "${ret,,}" in
  532. "sum" ) echo "$sum" ;;
  533. "size" ) echo "$size" ;;
  534. *) echo "$url";;
  535. esac
  536. return 0
  537. }
  538. getLink2() {
  539. local id="$1"
  540. local ret="$2"
  541. local url=""
  542. local sum=""
  543. local size=""
  544. local host="https://files.dog/MSDN"
  545. case "${id,,}" in
  546. "win81${PLATFORM,,}" )
  547. size=4320526336
  548. sum="d8333cf427eb3318ff6ab755eb1dd9d433f0e2ae43745312c1cd23e83ca1ce51"
  549. url="$host/Windows%208.1%20with%20Update/en_windows_8.1_with_update_${PLATFORM,,}_dvd_6051480.iso"
  550. ;;
  551. "win81${PLATFORM,,}-enterprise" | "win81${PLATFORM,,}-enterprise-eval" )
  552. size=4139163648
  553. sum="c3c604c03677504e8905090a8ce5bb1dde76b6fd58e10f32e3a25bef21b2abe1"
  554. url="$host/Windows%208.1%20with%20Update/en_windows_8.1_enterprise_with_update_${PLATFORM,,}_dvd_6054382.iso"
  555. ;;
  556. "win2012r2" | "win2012r2-eval" )
  557. size=5397889024
  558. sum="f351e89eb88a96af4626ceb3450248b8573e3ed5924a4e19ea891e6003b62e4e"
  559. url="$host/Windows%20Server%202012%20R2%20with%20Update/en_windows_server_2012_r2_with_update_${PLATFORM,,}_dvd_6052708.iso"
  560. ;;
  561. "win2008r2" | "win2008r2-eval" )
  562. size=3166584832
  563. sum="dfd9890881b7e832a927c38310fb415b7ea62ac5a896671f2ce2a111998f0df8"
  564. url="$host/Windows%20Server%202008%20R2/en_windows_server_2008_r2_with_sp1_${PLATFORM,,}_dvd_617601.iso"
  565. ;;
  566. "win7${PLATFORM,,}" | "win7${PLATFORM,,}-enterprise" )
  567. size=3182604288
  568. sum="ee69f3e9b86ff973f632db8e01700c5724ef78420b175d25bae6ead90f6805a7"
  569. url="$host/Windows%207/en_windows_7_enterprise_with_sp1_${PLATFORM,,}_dvd_u_677651.iso"
  570. ;;
  571. "win7${PLATFORM,,}-ultimate" )
  572. size=3320903680
  573. sum="36f4fa2416d0982697ab106e3a72d2e120dbcdb6cc54fd3906d06120d0653808"
  574. url="$host/Windows%207/en_windows_7_ultimate_with_sp1_${PLATFORM,,}_dvd_u_677332.iso"
  575. ;;
  576. "win7x86" | "win7x86enterprise" )
  577. size=2434502656
  578. sum="8bdd46ff8cb8b8de9c4aba02706629c8983c45e87da110e64e13be17c8434dad"
  579. url="$host/Windows%207/en_windows_7_enterprise_with_sp1_x86_dvd_u_677710.iso"
  580. ;;
  581. "win7x86-ultimate" )
  582. size=2564476928
  583. sum="e2c009a66d63a742941f5087acae1aa438dcbe87010bddd53884b1af6b22c940"
  584. url="$host/Windows%207/en_windows_7_ultimate_with_sp1_x86_dvd_u_677460.iso"
  585. ;;
  586. "winvista${PLATFORM,,}" | "winvista${PLATFORM,,}-enterprise" )
  587. size=3205953536
  588. sum="0a0cd511b3eac95c6f081419c9c65b12317b9d6a8d9707f89d646c910e788016"
  589. url="$host/Windows%20Vista/en_windows_vista_enterprise_sp2_${PLATFORM,,}_dvd_342332.iso"
  590. ;;
  591. "winvista${PLATFORM,,}-ultimate" )
  592. size=3861460992
  593. sum="edf9f947c5791469fd7d2d40a5dcce663efa754f91847aa1d28ed7f585675b78"
  594. url="$host/Windows%20Vista/en_windows_vista_sp2_${PLATFORM,,}_dvd_342267.iso"
  595. ;;
  596. "winvistax86" | "winvistax86-enterprise" )
  597. size=2420981760
  598. sum="54e2720004041e7db988a391543ea5228b0affc28efcf9303d2d0ff9402067f5"
  599. url="$host/Windows%20Vista/en_windows_vista_enterprise_sp2_x86_dvd_342329.iso"
  600. ;;
  601. "winvistax86-ultimate" )
  602. size=3243413504
  603. sum="9c36fed4255bd05a8506b2da88f9aad73643395e155e609398aacd2b5276289c"
  604. url="$host/Windows%20Vista/en_windows_vista_with_sp2_x86_dvd_342266.iso"
  605. ;;
  606. "winxpx86" )
  607. size=617756672
  608. sum="62b6c91563bad6cd12a352aa018627c314cfc5162d8e9f8af0756a642e602a46"
  609. url="$host/Windows%20XP/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
  610. ;;
  611. "winxpx64" )
  612. size=614166528
  613. sum="8fac68e1e56c64ad9a2aa0ad464560282e67fa4f4dd51d09a66f4e548eb0f2d6"
  614. url="$host/Windows%20XP/en_win_xp_pro_${PLATFORM,,}_vl.iso"
  615. ;;
  616. esac
  617. case "${ret,,}" in
  618. "sum" ) echo "$sum" ;;
  619. "size" ) echo "$size" ;;
  620. *) echo "$url";;
  621. esac
  622. return 0
  623. }
  624. getLink3() {
  625. local id="$1"
  626. local ret="$2"
  627. local url=""
  628. local sum=""
  629. local size=""
  630. local host="https://file.cnxiaobai.com/Windows"
  631. case "${id,,}" in
  632. "core11" )
  633. size=2159738880
  634. sum="78f0f44444ff95b97125b43e560a72e0d6ce0a665cf9f5573bf268191e5510c1"
  635. url="$host/%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E5%8C%85/Tiny%2010_11/tiny11%20core%20${PLATFORM,,}%20beta%201.iso"
  636. ;;
  637. "tiny11" )
  638. size=3788177408
  639. sum="a028800a91addc35d8ae22dce7459b67330f7d69d2f11c70f53c0fdffa5b4280"
  640. url="$host/%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E5%8C%85/Tiny%2010_11/tiny11%202311%20${PLATFORM,,}.iso"
  641. ;;
  642. "tiny10" )
  643. size=3839819776
  644. sum="a11116c0645d892d6a5a7c585ecc1fa13aa66f8c7cc6b03bf1f27bd16860cc35"
  645. url="$host/%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E5%8C%85/Tiny%2010_11/tiny10%2023H2%20${PLATFORM,,}.iso"
  646. ;;
  647. esac
  648. case "${ret,,}" in
  649. "sum" ) echo "$sum" ;;
  650. "size" ) echo "$size" ;;
  651. *) echo "$url";;
  652. esac
  653. return 0
  654. }
  655. getLink4() {
  656. # Fallbacks for users who cannot connect to the Microsoft servers
  657. local id="$1"
  658. local ret="$2"
  659. local url=""
  660. local sum=""
  661. local size=""
  662. local host="https://drive.massgrave.dev"
  663. case "${id,,}" in
  664. "win11${PLATFORM,,}" )
  665. size=7004780544
  666. sum="a6c21313210182e0315054789a2b658b77394d5544b69b5341075492f89f51e5"
  667. url="$host/en-us_windows_11_consumer_editions_version_23h2_updated_april_2024_${PLATFORM,,}_dvd_d986680b.iso"
  668. ;;
  669. "win11${PLATFORM,,}-enterprise" | "win11${PLATFORM,,}-enterprise-eval" )
  670. size=6879023104
  671. sum="3d4d388d6ffa371956304fa7401347b4535fd10e3137978a8f7750b790a43521"
  672. url="$host/en-us_windows_11_business_editions_version_23h2_updated_april_2024_${PLATFORM,,}_dvd_349cd577.iso"
  673. ;;
  674. "win11${PLATFORM,,}-iot" | "win11${PLATFORM,,}-enterprise-iot-eval" )
  675. size=6248140800
  676. sum="5d9b86ad467bc89f488d1651a6c5ad3656a7ea923f9f914510657a24c501bb86"
  677. url="$host/en-us_windows_11_iot_enterprise_version_23h2_${PLATFORM,,}_dvd_fb37549c.iso"
  678. ;;
  679. "win10${PLATFORM,,}" )
  680. size=6605459456
  681. sum="b072627c9b8d9f62af280faf2a8b634376f91dc73ea1881c81943c151983aa4a"
  682. url="$host/en-us_windows_10_consumer_editions_version_22h2_updated_april_2024_${PLATFORM,,}_dvd_9a92dc89.iso"
  683. ;;
  684. "win10${PLATFORM,,}-enterprise" | "win10${PLATFORM,,}-enterprise-eval" )
  685. size=6428377088
  686. sum="05fe9de04c2626bd00fbe69ad19129b2dbb75a93a2fe030ebfb2256d937ceab8"
  687. url="$host/en-us_windows_10_business_editions_version_22h2_updated_april_2024_${PLATFORM,,}_dvd_c00090a7.iso"
  688. ;;
  689. "win10${PLATFORM,,}-iot" | "win10${PLATFORM,,}-enterprise-iot-eval" )
  690. size=4851668992
  691. sum="a0334f31ea7a3e6932b9ad7206608248f0bd40698bfb8fc65f14fc5e4976c160"
  692. url="$host/en-us_windows_10_iot_enterprise_ltsc_2021_${PLATFORM,,}_dvd_257ad90f.iso"
  693. ;;
  694. "win10${PLATFORM,,}-ltsc" | "win10${PLATFORM,,}-enterprise-ltsc-eval" )
  695. size=4899461120
  696. sum="c90a6df8997bf49e56b9673982f3e80745058723a707aef8f22998ae6479597d"
  697. url="$host/en-us_windows_10_enterprise_ltsc_2021_${PLATFORM,,}_dvd_d289cf96.iso"
  698. ;;
  699. "win81${PLATFORM,,}-enterprise" | "win81${PLATFORM,,}-enterprise-eval" )
  700. size=4139163648
  701. sum="c3c604c03677504e8905090a8ce5bb1dde76b6fd58e10f32e3a25bef21b2abe1"
  702. url="$host/en_windows_8.1_enterprise_with_update_${PLATFORM,,}_dvd_6054382.iso"
  703. ;;
  704. "win2022" | "win2022-eval" )
  705. size=5515755520
  706. sum="7f41d603224e8a0bf34ba957d3abf0a02437ab75000dd758b5ce3f050963e91f"
  707. url="$host/en-us_windows_server_2022_updated_april_2024_${PLATFORM,,}_dvd_164349f3.iso"
  708. ;;
  709. "win2019" | "win2019-eval" )
  710. size=4843268096
  711. sum="4c5dd63efee50117986a2e38d4b3a3fbaf3c1c15e2e7ea1d23ef9d8af148dd2d"
  712. url="$host/en_windows_server_2019_${PLATFORM,,}_dvd_4cb967d8.iso"
  713. ;;
  714. "win2016" | "win2016-eval" )
  715. size=5653628928
  716. sum="4caeb24b661fcede81cd90661aec31aa69753bf49a5ac247253dd021bc1b5cbb"
  717. url="$host/en_windows_server_2016_${PLATFORM,,}_dvd_9327751.iso"
  718. ;;
  719. "win2012r2" | "win2012r2-eval" )
  720. size=5397889024
  721. sum="f351e89eb88a96af4626ceb3450248b8573e3ed5924a4e19ea891e6003b62e4e"
  722. url="$host/en_windows_server_2012_r2_with_update_${PLATFORM,,}_dvd_6052708.iso"
  723. ;;
  724. "win2008r2" | "win2008r2-eval" )
  725. size=3166584832
  726. sum="dfd9890881b7e832a927c38310fb415b7ea62ac5a896671f2ce2a111998f0df8"
  727. url="$host/en_windows_server_2008_r2_with_sp1_${PLATFORM,,}_dvd_617601.iso"
  728. ;;
  729. "win7${PLATFORM,,}" | "win7${PLATFORM,,}-enterprise" )
  730. size=3182604288
  731. sum="ee69f3e9b86ff973f632db8e01700c5724ef78420b175d25bae6ead90f6805a7"
  732. url="$host/en_windows_7_enterprise_with_sp1_${PLATFORM,,}_dvd_u_677651.iso"
  733. ;;
  734. "win7${PLATFORM,,}-ultimate" )
  735. size=3320903680
  736. sum="36f4fa2416d0982697ab106e3a72d2e120dbcdb6cc54fd3906d06120d0653808"
  737. url="$host/en_windows_7_ultimate_with_sp1_${PLATFORM,,}_dvd_u_677332.iso"
  738. ;;
  739. "win7x86" | "win7x86enterprise" )
  740. size=2434502656
  741. sum="8bdd46ff8cb8b8de9c4aba02706629c8983c45e87da110e64e13be17c8434dad"
  742. url="$host/en_windows_7_enterprise_with_sp1_x86_dvd_u_677710.iso"
  743. ;;
  744. "win7x86-ultimate" )
  745. size=2564476928
  746. sum="e2c009a66d63a742941f5087acae1aa438dcbe87010bddd53884b1af6b22c940"
  747. url="$host/en_windows_7_ultimate_with_sp1_x86_dvd_u_677460.iso"
  748. ;;
  749. "winvista${PLATFORM,,}" | "winvista${PLATFORM,,}-enterprise" )
  750. size=3205953536
  751. sum="0a0cd511b3eac95c6f081419c9c65b12317b9d6a8d9707f89d646c910e788016"
  752. url="$host/en_windows_vista_enterprise_sp2_${PLATFORM,,}_dvd_342332.iso"
  753. ;;
  754. "winvista${PLATFORM,,}-ultimate" )
  755. size=3861460992
  756. sum="edf9f947c5791469fd7d2d40a5dcce663efa754f91847aa1d28ed7f585675b78"
  757. url="$host/en_windows_vista_sp2_${PLATFORM,,}_dvd_342267.iso"
  758. ;;
  759. "winvistax86" | "winvistax86-enterprise" )
  760. size=2420981760
  761. sum="54e2720004041e7db988a391543ea5228b0affc28efcf9303d2d0ff9402067f5"
  762. url="$host/en_windows_vista_enterprise_sp2_x86_dvd_342329.iso"
  763. ;;
  764. "winvistax86-ultimate" )
  765. size=3243413504
  766. sum="9c36fed4255bd05a8506b2da88f9aad73643395e155e609398aacd2b5276289c"
  767. url="$host/en_windows_vista_with_sp2_x86_dvd_342266.iso"
  768. ;;
  769. esac
  770. case "${ret,,}" in
  771. "sum" ) echo "$sum" ;;
  772. "size" ) echo "$size" ;;
  773. *) echo "$url";;
  774. esac
  775. return 0
  776. }
  777. getLink5() {
  778. local id="$1"
  779. local ret="$2"
  780. local url=""
  781. local sum=""
  782. local size=""
  783. local host="https://archive.org/download"
  784. case "${id,,}" in
  785. "core11" )
  786. size=2159738880
  787. sum="78f0f44444ff95b97125b43e560a72e0d6ce0a665cf9f5573bf268191e5510c1"
  788. url="$host/tiny-11-core-x-64-beta-1/tiny11%20core%20${PLATFORM,,}%20beta%201.iso"
  789. ;;
  790. "tiny11" )
  791. size=3788177408
  792. sum="a028800a91addc35d8ae22dce7459b67330f7d69d2f11c70f53c0fdffa5b4280"
  793. url="$host/tiny11-2311/tiny11%202311%20${PLATFORM,,}.iso"
  794. ;;
  795. "tiny10" )
  796. size=3839819776
  797. sum="a11116c0645d892d6a5a7c585ecc1fa13aa66f8c7cc6b03bf1f27bd16860cc35"
  798. url="$host/tiny-10-23-h2/tiny10%20${PLATFORM,,}%2023h2.iso"
  799. ;;
  800. "winxpx86" )
  801. size=617756672
  802. sum="62b6c91563bad6cd12a352aa018627c314cfc5162d8e9f8af0756a642e602a46"
  803. url="$host/XPPRO_SP3_ENU/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
  804. ;;
  805. esac
  806. case "${ret,,}" in
  807. "sum" ) echo "$sum" ;;
  808. "size" ) echo "$size" ;;
  809. *) echo "$url";;
  810. esac
  811. return 0
  812. }
  813. getValue() {
  814. local val=""
  815. local id="$3"
  816. local type="$2"
  817. local func="getLink$1"
  818. if [ "$1" -gt 0 ] && [ "$1" -le "$MIRRORS" ]; then
  819. val=$($func "$id" "$type")
  820. fi
  821. echo "$val"
  822. return 0
  823. }
  824. getLink() {
  825. local url=""
  826. url=$(getValue "$1" "" "$2")
  827. echo "$url"
  828. return 0
  829. }
  830. getHash() {
  831. local sum=""
  832. sum=$(getValue "$1" "sum" "$2")
  833. echo "$sum"
  834. return 0
  835. }
  836. getSize() {
  837. local size=""
  838. size=$(getValue "$1" "size" "$2")
  839. echo "$size"
  840. return 0
  841. }
  842. isMido() {
  843. local id="$1"
  844. local sum
  845. sum=$(getMido "$id" "sum")
  846. [ -n "$sum" ] && return 0
  847. return 1
  848. }
  849. isESD() {
  850. local id="$1"
  851. local url
  852. url=$(getCatalog "$id" "url")
  853. [ -n "$url" ] && return 0
  854. return 1
  855. }
  856. validVersion() {
  857. local id="$1"
  858. local url
  859. isESD "$id" && return 0
  860. isMido "$id" && return 0
  861. for ((i=1;i<=MIRRORS;i++)); do
  862. url=$(getLink "$i" "$id")
  863. [ -n "$url" ] && return 0
  864. done
  865. return 1
  866. }
  867. migrateFiles() {
  868. local base="$1"
  869. local version="$2"
  870. local file=""
  871. [ -f "$base" ] && return 0
  872. [[ "${version,,}" == "tiny10" ]] && file="tiny10_${PLATFORM,,}_23h2.iso"
  873. [[ "${version,,}" == "tiny11" ]] && file="tiny11_2311_${PLATFORM,,}.iso"
  874. [[ "${version,,}" == "core11" ]] && file="tiny11_core_${PLATFORM,,}_beta_1.iso"
  875. [[ "${version,,}" == "winxpx86" ]] && file="en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso"
  876. [[ "${version,,}" == "winvista${PLATFORM,,}" ]] && file="en_windows_vista_sp2_${PLATFORM,,}_dvd_342267.iso"
  877. [[ "${version,,}" == "win7${PLATFORM,,}" ]] && file="en_windows_7_enterprise_with_sp1_${PLATFORM,,}_dvd_u_677651.iso"
  878. [ ! -f "$STORAGE/$file" ] && return 0
  879. ! mv -f "$STORAGE/$file" "$base" && return 1
  880. return 0
  881. }
  882. configXP() {
  883. local dir="$1"
  884. local arch="x86"
  885. local target="$dir/I386"
  886. local drivers="$TMP/drivers"
  887. if [ -d "$dir/AMD64" ]; then
  888. arch="amd64"
  889. target="$dir/AMD64"
  890. fi
  891. rm -rf "$drivers"
  892. if ! 7z x /run/drivers.iso -o"$drivers" > /dev/null; then
  893. error "Failed to extract driver ISO file!" && return 1
  894. fi
  895. cp "$drivers/viostor/xp/$arch/viostor.sys" "$target"
  896. mkdir -p "$dir/\$OEM\$/\$1/Drivers/viostor"
  897. cp "$drivers/viostor/xp/$arch/viostor.cat" "$dir/\$OEM\$/\$1/Drivers/viostor"
  898. cp "$drivers/viostor/xp/$arch/viostor.inf" "$dir/\$OEM\$/\$1/Drivers/viostor"
  899. cp "$drivers/viostor/xp/$arch/viostor.sys" "$dir/\$OEM\$/\$1/Drivers/viostor"
  900. mkdir -p "$dir/\$OEM\$/\$1/Drivers/NetKVM"
  901. cp "$drivers/NetKVM/xp/$arch/netkvm.cat" "$dir/\$OEM\$/\$1/Drivers/NetKVM"
  902. cp "$drivers/NetKVM/xp/$arch/netkvm.inf" "$dir/\$OEM\$/\$1/Drivers/NetKVM"
  903. cp "$drivers/NetKVM/xp/$arch/netkvm.sys" "$dir/\$OEM\$/\$1/Drivers/NetKVM"
  904. if [ ! -f "$target/TXTSETUP.SIF" ]; then
  905. error "The file TXTSETUP.SIF could not be found!" && return 1
  906. fi
  907. sed -i '/^\[SCSI.Load\]/s/$/\nviostor=viostor.sys,4/' "$target/TXTSETUP.SIF"
  908. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\nviostor.sys=1,,,,,,4_,4,1,,,1,4/' "$target/TXTSETUP.SIF"
  909. sed -i '/^\[SCSI\]/s/$/\nviostor=\"Red Hat VirtIO SCSI Disk Device\"/' "$target/TXTSETUP.SIF"
  910. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00000000=\"viostor\"/' "$target/TXTSETUP.SIF"
  911. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00020000=\"viostor\"/' "$target/TXTSETUP.SIF"
  912. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00021AF4=\"viostor\"/' "$target/TXTSETUP.SIF"
  913. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00000000=\"viostor\"/' "$target/TXTSETUP.SIF"
  914. mkdir -p "$dir/\$OEM\$/\$1/Drivers/sata"
  915. cp -a "$drivers/sata/xp/$arch/." "$dir/\$OEM\$/\$1/Drivers/sata"
  916. cp -a "$drivers/sata/xp/$arch/." "$target"
  917. sed -i '/^\[SCSI.Load\]/s/$/\niaStor=iaStor.sys,4/' "$target/TXTSETUP.SIF"
  918. sed -i '/^\[FileFlags\]/s/$/\niaStor.sys = 16/' "$target/TXTSETUP.SIF"
  919. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.cat = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  920. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.inf = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  921. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.sys = 1,,,,,,4_,4,1,,,1,4/' "$target/TXTSETUP.SIF"
  922. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.sys = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  923. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaahci.cat = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  924. sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaAHCI.inf = 1,,,,,,,1,0,0/' "$target/TXTSETUP.SIF"
  925. sed -i '/^\[SCSI\]/s/$/\niaStor=\"Intel\(R\) SATA RAID\/AHCI Controller\"/' "$target/TXTSETUP.SIF"
  926. sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_8086\&DEV_2922\&CC_0106=\"iaStor\"/' "$target/TXTSETUP.SIF"
  927. local key pid setup
  928. setup=$(find "$target" -maxdepth 1 -type f -iname setupp.ini | head -n 1)
  929. pid=$(<"$setup")
  930. pid="${pid:(-4)}"
  931. pid="${pid:0:3}"
  932. if [[ "$pid" == "270" ]]; then
  933. info "Warning: this XP version requires a volume license, it will reject the generic key during installation."
  934. fi
  935. if [[ "${arch,,}" == "x86" ]]; then
  936. # Windows XP Professional x86 generic key (no activation, trial-only)
  937. # This is not a pirated key, it comes from the official MS documentation.
  938. key="DR8GV-C8V6J-BYXHG-7PYJR-DB66Y"
  939. else
  940. # Windows XP Professional x64 generic key (no activation, trial-only)
  941. # This is not a pirated key, it comes from the official MS documentation.
  942. key="B2RBK-7KPT9-4JP6X-QQFWM-PJD6G"
  943. fi
  944. find "$target" -maxdepth 1 -type f -iname winnt.sif -exec rm {} \;
  945. { echo "[Data]"
  946. echo "AutoPartition=1"
  947. echo "MsDosInitiated=\"0\""
  948. echo "UnattendedInstall=\"Yes\""
  949. echo "AutomaticUpdates=\"Yes\""
  950. echo ""
  951. echo "[Unattended]"
  952. echo "UnattendSwitch=Yes"
  953. echo "UnattendMode=FullUnattended"
  954. echo "FileSystem=NTFS"
  955. echo "OemSkipEula=Yes"
  956. echo "OemPreinstall=Yes"
  957. echo "Repartition=Yes"
  958. echo "WaitForReboot=\"No\""
  959. echo "DriverSigningPolicy=\"Ignore\""
  960. echo "NonDriverSigningPolicy=\"Ignore\""
  961. echo "OemPnPDriversPath=\"Drivers\viostor;Drivers\NetKVM;Drivers\sata\""
  962. echo "NoWaitAfterTextMode=1"
  963. echo "NoWaitAfterGUIMode=1"
  964. echo "FileSystem-ConvertNTFS"
  965. echo "ExtendOemPartition=0"
  966. echo "Hibernation=\"No\""
  967. echo ""
  968. echo "[GuiUnattended]"
  969. echo "OEMSkipRegional=1"
  970. echo "OemSkipWelcome=1"
  971. echo "AdminPassword=*"
  972. echo "TimeZone=0"
  973. echo "AutoLogon=Yes"
  974. echo "AutoLogonCount=65432"
  975. echo ""
  976. echo "[UserData]"
  977. echo "FullName=\"Docker\""
  978. echo "ComputerName=\"*\""
  979. echo "OrgName=\"Windows for Docker\""
  980. echo "ProductKey=$key"
  981. echo ""
  982. echo "[Identification]"
  983. echo "JoinWorkgroup = WORKGROUP"
  984. echo ""
  985. echo "[Networking]"
  986. echo "InstallDefaultComponents=Yes"
  987. echo ""
  988. echo "[Branding]"
  989. echo "BrandIEUsingUnattended=Yes"
  990. echo ""
  991. echo "[URL]"
  992. echo "Home_Page = http://www.google.com"
  993. echo "Search_Page = http://www.google.com"
  994. echo ""
  995. echo "[RegionalSettings]"
  996. echo "Language=00000409"
  997. echo ""
  998. echo "[TerminalServices]"
  999. echo "AllowConnections=1"
  1000. } | unix2dos > "$target/WINNT.SIF"
  1001. { echo "Windows Registry Editor Version 5.00"
  1002. echo ""
  1003. echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security]"
  1004. echo "\"FirstRunDisabled\"=dword:00000001"
  1005. echo "\"AntiVirusOverride\"=dword:00000001"
  1006. echo "\"FirewallOverride\"=dword:00000001"
  1007. echo "\"FirewallDisableNotify\"=dword:00000001"
  1008. echo "\"UpdatesDisableNotify\"=dword:00000001"
  1009. echo "\"AntiVirusDisableNotify\"=dword:00000001"
  1010. echo ""
  1011. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wscsvc]"
  1012. echo "\"Start\"=dword:00000004"
  1013. echo ""
  1014. echo "[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\WindowsFirewall\StandardProfile]"
  1015. echo "\"EnableFirewall\"=dword:00000000"
  1016. echo ""
  1017. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess]"
  1018. echo "\"Start\"=dword:00000004"
  1019. echo
  1020. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List]"
  1021. echo "\"3389:TCP\"=\"3389:TCP:*:Enabled:@xpsp2res.dll,-22009\""
  1022. echo ""
  1023. echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]"
  1024. echo "\"LimitBlankPasswordUse\"=dword:00000000"
  1025. echo ""
  1026. echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Tour]"
  1027. echo "\"RunCount\"=dword:00000000"
  1028. echo ""
  1029. echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]"
  1030. echo "\"HideFileExt\"=dword:00000000"
  1031. echo ""
  1032. echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]"
  1033. echo "\"DefaultUserName\"=\"Docker\""
  1034. echo "\"DefaultDomainName\"=\"Dockur\""
  1035. echo "\"AltDefaultUserName\"=\"Docker\""
  1036. echo "\"AltDefaultDomainName\"=\"Dockur\""
  1037. echo "\"AutoAdminLogon\"=\"1\""
  1038. } | unix2dos > "$dir/\$OEM\$/install.reg"
  1039. { echo "Set WshShell = WScript.CreateObject(\"WScript.Shell\")"
  1040. echo "Set WshNetwork = WScript.CreateObject(\"WScript.Network\")"
  1041. echo "Set oMachine = GetObject(\"WinNT://\" & WshNetwork.ComputerName)"
  1042. echo "Set oInfoUser = GetObject(\"WinNT://\" & WshNetwork.ComputerName & \"/Administrator,user\")"
  1043. echo "Set oUser = oMachine.MoveHere(oInfoUser.ADsPath,\"Docker\")"
  1044. } | unix2dos > "$dir/\$OEM\$/admin.vbs"
  1045. { echo "[COMMANDS]"
  1046. echo "\"REGEDIT /s install.reg\""
  1047. echo "\"Wscript admin.vbs\""
  1048. } | unix2dos > "$dir/\$OEM\$/cmdlines.txt"
  1049. rm -rf "$drivers"
  1050. return 0
  1051. }
  1052. prepareXP() {
  1053. local iso="$1"
  1054. local dir="$2"
  1055. ETFS="[BOOT]/Boot-NoEmul.img"
  1056. [[ "$MANUAL" == [Yy1]* ]] && return 0
  1057. configXP "$dir" && return 0
  1058. return 1
  1059. }
  1060. prepareLegacy() {
  1061. local iso="$1"
  1062. local dir="$2"
  1063. local file="$dir/boot.img"
  1064. ETFS=$(basename "$file")
  1065. [ -f "$file" ] && [ -s "$file" ] && return 0
  1066. rm -f "$file"
  1067. local len offset
  1068. len=$(isoinfo -d -i "$iso" | grep "Nsect " | grep -o "[^ ]*$")
  1069. offset=$(isoinfo -d -i "$iso" | grep "Bootoff " | grep -o "[^ ]*$")
  1070. dd "if=$iso" "of=$file" bs=2048 "count=$len" "skip=$offset" status=none && return 0
  1071. return 1
  1072. }
  1073. return 0