define.sh 38 KB

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