-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootdisk.sh
833 lines (773 loc) · 26.5 KB
/
bootdisk.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
#!/usr/bin/env bash
# bootdisk.sh - menus and options
#
# Copyright (C) 2024 Joseph P. Zeller
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
title_block () {
cat<<EOF
===========================
---BOOTDISK v1.6---
Flash Drive Formatting Tool
===========================
Select an option:
EOF
}
lower_border () {
cat<<EOF
===========================
EOF
}
menu_all () {
while :
do
clear
title_block
cat<<EOF
FreeDOS 1.3 (1)
MS-DOS 8.0 (2)
Windows 7-11 (3)
UEFI Shell (4)
Tools Menu (5)
About (6)
Quit (7)
EOF
lower_border
read -p"Enter Choice: "
case "$REPLY" in
"1") fdosdisk ;;
"2") msdosdisk ;;
"3") windowsmode ;;
"4") uefi_shell ;;
"5") menu_tools ;;
"6") show_about ;;
"7") exit ;;
* ) select_err ;;
esac
done
}
menu_standard () {
while :
do
clear
title_block
cat<<EOF
FreeDOS 1.3 (1)
Windows 7-11 (2)
UEFI Shell (3)
Tools Menu (4)
About (5)
Quit (6)
EOF
lower_border
read -p"Enter Choice: "
case "$REPLY" in
"1") fdosdisk ;;
"2") windowsmode ;;
"3") uefi_shell ;;
"4") menu_tools ;;
"5") show_about ;;
"6") exit ;;
* ) select_err ;;
esac
done
}
menu_uefi () {
while :
do
clear
title_block
cat<<EOF
Windows 7-11 (1)
UEFI Shell (2)
Tools Menu (3)
About (4)
Quit (5)
EOF
lower_border
read -p"Enter Choice: "
case "$REPLY" in
"1") windowsmode ;;
"2") uefi_shell ;;
"3") menu_tools ;;
"4") show_about ;;
"5") exit ;;
* ) select_err ;;
esac
done
}
menu_tools () {
while :
do
clear
title_block
cat<<EOF
Extract MS-DOS 8.0 (1)
Download an ISO file (2)
Verify Windows ISO checksum (3)
Custom Windows installation (4)
Return to Main Menu (5)
EOF
lower_border
read -p"Enter Choice: "
case "$REPLY" in
"1") extractdos ;;
"2") fido_script ;;
"3") checksum ;;
"4") customize ;;
"5") break ;;
* ) select_err ;;
esac
done
}
fdosdisk () {
clear
echo " FreeDOS 1.3 Boot Disk Script "
echo "-----------------------------------"
if [[ "$system" == "Darwin" ]]; then
read -p "Enter target disk [disk#]: " tgtdsk
while [[ $tgtdsk != *"disk"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [disk#]: " tgtdsk
done
elif [[ "$system" == "Linux" ]]; then
read -p "Enter target disk [sd*]: " tgtdsk
while [[ $tgtdsk != *"sd"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [sd*]: " tgtdsk
done
fi
read -p "Enter file system [FAT16/FAT32]: " fstyp
fstyp=${fstyp^^}
while [[ $fstyp != "FAT16" && $fstyp != "FAT32" ]]; do
echo -e "${RED}Invalid file system type. Try again.${NC}"
read -p "Enter file system [FAT16/FAT32]: " fstyp
fstyp=${fstyp^^}
done
read -p "Enter label [FREEDOS]: " volname
if [[ "$volname" == "" ]]; then volname=FREEDOS; fi
volname=${volname^^}
n=${#volname}
while [ $n -gt 11 ]; do
echo -e "${RED}Label must be eleven characters or less.${NC}"
read -p "Enter label [WINDOWS]: " volname
n=${#volname}
done
echo
(cd $resdir/FreeDOS; ./freedosdisk.sh $system $fstyp "$volname" $tgtdsk)
}
msdosdisk () {
clear
echo " MS-DOS 8.0 Boot Disk Script "
echo "-----------------------------------"
if [[ "$system" == "Darwin" ]]; then
read -p "Enter target disk [disk#]: " tgtdsk
while [[ $tgtdsk != *"disk"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [disk#]: " tgtdsk
done
elif [[ "$system" == "Linux" ]]; then
read -p "Enter target disk [sd*]: " tgtdsk
while [[ $tgtdsk != *"sd"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [sd*]: " tgtdsk
done
fi
read -p "Enter file system [FAT16/FAT32]: " fstyp
fstyp=${fstyp^^}
while [[ $fstyp != "FAT16" && $fstyp != "FAT32" ]]; do
echo -e "${RED}Invalid file system type. Try again.${NC}"
read -p "Enter file system [FAT16/FAT32]: " fstyp
fstyp=${fstyp^^}
done
read -p "Enter label [MSDOS80]: " volname
if [[ "$volname" == "" ]]; then volname=MSDOS80; fi
volname=${volname^^}
n=${#volname}
while [ $n -gt 11 ]; do
echo -e "${RED}Label must be eleven characters or less.${NC}"
read -p "Enter label [MSDOS80]: " volname
n=${#volname}
done
echo
(cd $resdir/MS-DOS; ./msdosdisk.sh $system $fstyp "$volname" $tgtdsk)
}
windowsmode () {
wtgsupport="false"
if [[ "$system" == "Darwin" ]]; then
personality=$(diskutil listFilesystems | grep NTFS | awk '{print $1}')
if [[ $personality == "Tuxera" || $personality == "UFSD_NTFS" ||
(! -z $(command -v mkntfs) && ! -z $(command -v ntfs-3g)) ]]; then
if [[ $wimtools == "true" && ! -z $(command -v bcd-sys) ]]; then
wtgsupport="true"
fi
fi
elif [[ "$system" == "Linux" ]]; then
if [[ ! -z $(command -v mkntfs) && ! -z $(command -v ntfs-3g) ]]; then
if [[ $wimtools == "true" && ! -z $(command -v bcd-sys) ]]; then
wtgsupport="true"
fi
fi
fi
if [[ $wtgsupport == "true" ]]; then
while :
do
clear
title_block
echo "Create install media (1)"
echo "Create Windows to Go (2)"
echo "Return to Main Menu (3)"
lower_border
read -p"Enter Choice: "
case "$REPLY" in
"1") windowsdisk ;;
"2") windowstogo ;;
"3") break ;;
* ) select_err ;;
esac
done
else
windowsdisk
fi
}
windowsdisk () {
clear
echo " Windows Boot Disk Script "
echo "-----------------------------------"
if [[ "$system" == "Darwin" ]]; then
read -p "Enter target disk [disk#]: " tgtdsk
while [[ $tgtdsk != *"disk"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [disk#]: " tgtdsk
done
elif [[ "$system" == "Linux" ]]; then
read -p "Enter target disk [sd*]: " tgtdsk
while [[ $tgtdsk != *"sd"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [sd*]: " tgtdsk
done
fi
read -p "Enter partition scheme [GPT/MBR]: " prtshm
prtshm=${prtshm^^}
while [[ $prtshm != "GPT" && $prtshm != "MBR" ]]; do
echo -e "${RED}Invalid partition scheme. Try again.${NC}"
read -p "Enter partition scheme [GPT/MBR]: " prtshm
prtshm=${prtshm^^}
done
if [[ "$system" == "Darwin" ]]; then
if [[ $personality == "Tuxera" || $personality == "UFSD_NTFS" ]]; then
read -p "Enter file system [FAT32/EXFAT/NTFS]: " fstyp
fstyp=${fstyp^^}
while [[ $fstyp != "FAT32" && $fstyp != "EXFAT" && $fstyp != "NTFS" ]]; do
echo -e "${RED}Invalid file system type. Try again.${NC}"
read -p "Enter file system [FAT32/EXFAT/NTFS]: " fstyp
fstyp=${fstyp^^}
done
else
read -p "Enter file system [FAT32/EXFAT]: " fstyp
fstyp=${fstyp^^}
while [[ $fstyp != "FAT32" && $fstyp != "EXFAT" ]]; do
echo -e "${RED}Invalid file system type. Try again.${NC}"
read -p "Enter file system [FAT32/EXFAT]: " fstyp
fstyp=${fstyp^^}
done
fi
elif [[ "$system" == "Linux" ]]; then
read -p "Enter file system [FAT32/EXFAT/NTFS]: " fstyp
fstyp=${fstyp^^}
while [[ $fstyp != "FAT32" && $fstyp != "EXFAT" && $fstyp != "NTFS" ]]; do
echo -e "${RED}Invalid file system type. Try again.${NC}"
read -p "Enter file system [FAT32/EXFAT/NTFS]: " fstyp
fstyp=${fstyp^^}
done
fi
if [[ $fstyp == "EXFAT" || $fstyp == "NTFS" ]] && [[ -e $resdir/Support/uefi-ntfs.img ]]; then
read -p "Enable UEFI boot support [Y/N]? " uefint
uefint=${uefint^^}
while [[ $uefint != "Y" && $uefint != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Enable UEFI boot support [Y/N]? " uefint
uefint=${uefint^^}
done
else
uefint="N"
fi
read -p "Enter label [WINDOWS]: " volname
n=${#volname}
if [[ $fstyp == "FAT32" || $fstyp == "EXFAT" ]]; then
if [[ $fstyp == "FAT32" ]]; then volname=${volname^^}; fi
while [ $n -gt 11 ]; do
echo -e "${RED}Label must be eleven characters or less.${NC}"
read -p "Enter label [WINDOWS]: " volname
n=${#volname}
done
elif [[ "$system" == "Linux" && $fstyp == "NTFS" ]]; then
while [ $n -gt 128 ]; do
echo -e "${RED}Label must be 128 characters or less.${NC}"
read -p "Enter label [WINDOWS]: " volname
n=${#volname}
done
fi
if [[ "$volname" == "" ]]; then volname=WINDOWS; fi
read -p "Enter ISO path [NONE]: " image
if [[ "$image" == "" ]]; then image=NONE; fi
echo
(cd $resdir/Windows; ./windowsdisk.sh $system $prtshm $fstyp $uefint "$volname" "$image" $wimtools $tgtdsk)
}
wtgtitle () {
clear
echo " Windows to Go Script "
echo "--------------------------------"
}
windowstogo () {
wtgtitle
if [[ "$system" == "Darwin" ]]; then
read -p "Enter target disk [disk#]: " tgtdsk
while [[ $tgtdsk != *"disk"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [disk#]: " tgtdsk
done
elif [[ "$system" == "Linux" ]]; then
read -p "Enter target disk [sd*]: " tgtdsk
while [[ $tgtdsk != *"sd"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [sd*]: " tgtdsk
done
fi
read -p "Enter path to ISO file: " image
while [[ ! -f "$image" || "$image" != *.iso ]]; do
echo -e "${RED}Invalid file. Please try again.${NC}"
read -p "Enter path to ISO file: " image
done
echo "Mount install disk image..."
if [[ "$system" == "Darwin" ]]; then
wimfile="/tmp/isomount/sources/install.wim"
hdiutil attach "$image" -mountpoint /tmp/isomount -nobrowse > /dev/null
elif [[ "$system" == "Linux" ]]; then
wimfile="/mnt/isomount/sources/install.wim"
if [[ ! -f $wimfile ]]; then
sudo mkdir -p /mnt/isomount
sudo mount -o loop "$image" /mnt/isomount
fi
fi
if [[ ! -f $wimfile ]]; then
echo -e "${RED}Unable to find install archive in DVD image.${NC}"
echo
read -p "Press any key to continue... " -n1 -s
return 1
fi
wtgtitle
idxnum=$(wiminfo $wimfile | grep -E '^(Index:)' | cut -d " " -f2- | sed 's/^[[:space:]]*//g;s/[0-9]$/&\./g')
prodname=$(wiminfo $wimfile | grep -E '^(Name:)' | cut -d " " -f2- | sed 's/^[[:space:]]*//g')
echo "Windows products on $(basename "$image")"
paste <(printf %s "$idxnum") <(printf %s "$prodname")
read -p "Enter Choice (q to Quit): " index
while [[ $idxnum != *$index* && $index != "q" ]]; do
echo -e "${RED}Invalid entry. Please try again.${NC}"
read -p "Enter Choice: " index
done
if [[ "$index" != "q" ]]; then
echo
(cd $resdir/Windows; ./windowstogo.sh $system $wimfile $index $tgtdsk)
fi
if [[ ! $? -eq 0 ]]; then wtgerror="true"; else wtgerror="false"; fi
rm -f /tmp/wimfile_errors.txt
echo "Unmount install disk image..."
if [[ "$system" == "Darwin" ]]; then
hdiutil detach /tmp/isomount > /dev/null
elif [[ "$system" == "Linux" ]]; then
sudo umount /mnt/isomount && sudo rm -d /mnt/isomount
fi
if [[ $wtgerror == "true" ]]; then
echo
read -p "Press any key to continue... " -n1 -s
else
echo "Finished!"
sleep 2
fi
}
uefi_shell () {
clear
echo " UEFI Shell Disk Script "
echo "----------------------------------"
read -p "Wipe disk before extracting files [Y/N]? " wipe
wipe=${wipe^^}
while [[ $wipe != "Y" && $wipe != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Wipe disk before extracting files [Y/N]? " wipe
wipe=${wipe^^}
done
if [[ $wipe == "Y" ]]; then
if [[ "$system" == "Darwin" ]]; then
read -p "Enter target disk [disk#]: " target
while [[ $target != *"disk"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [disk#]: " target
done
elif [[ "$system" == "Linux" ]]; then
read -p "Enter target disk [sd*]: " target
while [[ $target != *"sd"* ]]; do
echo -e "${RED}Invalid disk name. Try again.${NC}"
read -p "Enter target disk [sd*]: " target
done
fi
read -p "Enter partition scheme [GPT/MBR]: " prtshm
prtshm=${prtshm^^}
while [[ $prtshm != "GPT" && $prtshm != "MBR" ]]; do
echo -e "${RED}Invalid partition scheme. Try again.${NC}"
read -p "Enter partition scheme [GPT/MBR]: " prtshm
prtshm=${prtshm^^}
done
read -p "Enter file system [FAT16/FAT32]: " fstyp
fstyp=${fstyp^^}
while [[ $fstyp != "FAT16" && $fstyp != "FAT32" ]]; do
echo -e "${RED}Invalid file system type. Try again.${NC}"
read -p "Enter file system [FAT16/FAT32]: " fstyp
fstyp=${fstyp^^}
done
read -p "Enter label [UEFI_SHELL]: " volname
if [[ "$volname" == "" ]]; then volname="UEFI_SHELL"; fi
volname=${volname^^}
n=${#volname}
while [ $n -gt 11 ]; do
echo -e "${RED}Label must be eleven characters or less.${NC}"
read -p "Enter label [UEFI_SHELL]: " volname
n=${#volname}
done
else
if [[ "$system" == "Darwin" ]]; then
read -p "Enter path to disk [/Volumes/Untitled]: " target
elif [[ "$system" == "Linux" ]]; then
read -p "Enter path to disk [/media/user/USBDISK]: " target
fi
prtshm="CURRENT"
fstyp="N/A"
volname="N/A"
fi
read -p "Enter ISO path: " image
while [[ "$image" != *".iso"* ]]; do
echo -e "${RED}Invalid file type. Try again.${NC}"
read -p "Enter ISO path: " image
done
echo
(cd $resdir/Support; ./uefishelldisk.sh $system "$image" "$target" $prtshm $fstyp "$volname")
}
fido_title () {
clear
echo " Download an ISO file using Fido "
echo "-----------------------------------"
}
fido_script () {
fido_title
# Download script if missing or not current version then patch for Unix platforms.
fido_url="https://github.com/pbatard/Fido/releases/latest"
fido_url_ver=$(curl -IkLs -o /dev/null -w %{url_effective} $fido_url | grep -o "[^/]*$"| sed "s/v//g")
if [[ ! -e $resdir/Support/Fido.ps1 || "$(grep "# Fido v" $resdir/Support/Fido.ps1 | tr -d [:alpha:] | awk '{print $2}')" != "$fido_url_ver" ]]; then
rm -f $resdir/Support/Fido.* 2> /dev/null && curl -Lo $resdir/Support/Fido.ps1.lzma $fido_url/download/Fido.ps1.lzma 2> /dev/null
7z e $resdir/Support/Fido.ps1.lzma -o$resdir/Support/ > /dev/null
perl -i -pe's/\$version = 0.0/\$version = 10.0/' $resdir/Support/Fido.ps1 # Return the equivalent of Windows 10 by default.
perl -i -pe's/"en-us"; Id = 0/"en-us"; Id = 1/' $resdir/Support/Fido.ps1 # Set language Id to one for UEFI Shell downloads.
perl -i -pe's/curl/Invoke-WebRequest/' $resdir/Support/Fido.ps1 # Switch back to Invoke-WebRequest for Unix compatibility.
perl -i -pe's/Start-BitsTransfer -Source \$Url -Destination/Invoke-WebRequest -UseBasicParsing -TimeoutSec \$DefaultTimeout -Uri \$Url -OutFile/' $resdir/Support/Fido.ps1 # Use Invoke-WebRequest for ISO downloads since BITS is not available on Unix.
fi
# Check if PowerShell is supported and run script.
version=$(pwsh -Version | awk '{print $NF}')
fido_prompt="Please enter your choice (q to Quit): "
if [ "$(printf '%s\n' "3.0" "$version" | sort -V | head -n1)" = "3.0" ]; then
pwsh $resdir/Support/Fido.ps1 -Win List
read -p "$fido_prompt" winver
if [[ "$winver" == "q" ]]; then return; fi
fido_title
pwsh $resdir/Support/Fido.ps1 -Win $winver -Rel List
read -p "$fido_prompt" release
if [[ "$release" == "q" ]]; then return; fi
fido_title
pwsh $resdir/Support/Fido.ps1 -Win $winver -Rel $release -Ed List
read -p "$fido_prompt" edition
if [[ "$edition" == "q" ]]; then return; fi
fido_title
pwsh $resdir/Support/Fido.ps1 -Win $winver -Rel $release -Ed $edition -Lang List
read -p "$fido_prompt" lang
if [[ "$lang" == "q" ]]; then return; fi
fido_title
pwsh $resdir/Support/Fido.ps1 -Win $winver -Rel $release -Ed $edition -Lang $lang -Arch List
read -p "$fido_prompt" arch
if [[ "$arch" == "q" ]]; then return; fi
fido_title
cd ~/Downloads
pwsh $resdir/Support/Fido.ps1 -Win $winver -Rel $release -Ed $edition -Lang $lang -Arch $arch
sleep 1
cd -
else
echo "PowerShell version 3.0 or higher required."
echo
read -n 1 -s -r -p "Press any key to continue"
fi
}
checksum () {
clear
echo " Verify SHA-1 checksum of an ISO file "
echo "----------------------------------------------"
read -p "Enter path to Windows ISO file: " file
echo "Calculating checksum..."
isosum=$(shasum "$file" | awk '{print $1}')
echo "Searching on adguard.net..."
python3 -m webbrowser "https://sha1.rg-adguard.net/search.php?sha1=$isosum"
read -p "Press any key to continue... " -n1 -s
}
extractdos () {
clear
echo " Extract MS-DOS 8.0 files "
echo "----------------------------------"
read -p "Enter path to diskcopy.dll: " file
echo
(cd $resdir/Support; ./extract_msdos.sh "$file")
}
customize () {
clear
echo " Customize your Windows Installation "
echo "-------------------------------------------"
if [[ "$system" == "Darwin" ]]; then
read -p "Enter path to Windows disk [/Volumes/Windows]: " windisk
elif [[ "$system" == "Linux" ]]; then
read -p "Enter path to Windows disk [/media/$USER/Windows]: " windisk
fi
if [[ ! -d $windisk ]]; then
echo
echo "Unable to access path:" $windisk
echo
read -p "Press any key to continue... " -n1 -s
return 1
fi
if [[ -f "$windisk/sources/boot.wim" ]]; then
winmedia="install"
elif [[ -f "$windisk/Windows/Boot/EFI/bootmgfw.efi" ]]; then
winmedia="wintogo"
else
echo
echo "Unable to locate the Windows files."
echo
read -p "Press any key to continue... " -n1 -s
return 1
fi
unsupported="false"
bypassnro="false"
# Check for Windows 11 media and provide options to disable hardware and Microsoft account requirements.
if [[ $winmedia == "install" && $wimtools == "true" ]]; then
if [[ $(wiminfo "$windisk"/sources/install.* 1 | grep -m 1 Name: | sed "s/^.*: *//") == "Windows 11"* ]]; then win11opts; fi
elif [[ $winmedia == "wintogo" && ! -z $(command -v hivexsh) ]]; then
bcdpath="/Volumes/UFD-SYSTEM/EFI/Microsoft/Boot/BCD"
if [[ -f "$bcdpath" ]]; then
guidscript="cd Objects\\{9dea862c-5cdd-4e70-acc1-f32b344d4795}\\\Elements\\\23000003\nlsval Element\nunload\n"
winguid=$(printf "$guidscript" | hivexsh "$bcdpath")
namescript="cd Objects\\$winguid\\\Elements\\\12000004\nlsval Element\nunload\n"
winprod=$(printf "$namescript" | hivexsh "$bcdpath")
if [[ "$winprod" == "Windows 11" ]]; then win11opts; fi
fi
else
read -p "Is this a Windows 11 disk [Y/N]? " eleven
eleven=${eleven^^}
while [[ $eleven != "Y" && $eleven != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Is this a Windows 11 disk [Y/N]? " eleven
eleven=${eleven^^}
done
if [[ $eleven == "Y" ]]; then win11opts; fi
fi
localize="false"
read -p "Use the current language settings on this system [Y/N]? " uselocale
uselocale=${uselocale^^}
while [[ $uselocale != "Y" && $uselocale != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Use the current language settings on this system [Y/N]? " uselocale
uselocale=${uselocale^^}
done
if [[ $uselocale == "Y" ]]; then localize="true"; fi
settimezone="false"
if [[ $(command -v pwsh) != "" ]]; then
read -p "Use the current timezone setting on this system [Y/N]? " usetimezone
usetimezone=${usetimezone^^}
while [[ $usetimezone != "Y" && $usetimezone != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Use the current timezone setting on this system [Y/N]? " usetimezone
usetimezone=${usetimezone^^}
done
if [[ $usetimezone == "Y" ]]; then settimezone="true"; fi
fi
useraccounts="false"
read -p "Create a local user account [Y/N]? " newuser
newuser=${newuser^^}
while [[ $newuser != "Y" && $newuser != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Create a local user account [Y/N]? " newuser
newuser=${newuser^^}
done
if [[ $newuser == "Y" ]]; then
useraccounts="true"
read -p "Enter a login name for new account [$USER]: " loginname
if [[ $loginname == "" ]]; then
loginname="$USER"
fi
if [[ $system == "Darwin" ]]; then
username=$(id -F)
elif [[ $system == "Linux" ]]; then
username=$(getent passwd $USER | awk -F: '{print $5}')
fi
read -p "Enter the full name for new account [$username]: " fullname
if [[ $fullname == "" ]]; then
fullname="$username"
fi
read -p "Enter a description for new account: " description
fi
skipwifisetup="false"
read -p "Skip the Join Wireless Network screen [Y/N]? " wifiscreen
wifiscreen=${wifiscreen^^}
while [[ $wifiscreen != "Y" && $wifiscreen != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Skip the Join Wireless Network screen [Y/N]? " wifiscreen
wifiscreen=${wifiscreen^^}
done
if [[ $wifiscreen == "Y" ]]; then skipwifisetup="true"; fi
disdatacol="false"
read -p "Disable data collection and privacy questions [Y/N]? " privacy
privacy=${privacy^^}
while [[ $privacy != "Y" && $privacy != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Disable data collection and privacy questions [Y/N]? " privacy
privacy=${privacy^^}
done
if [[ $privacy == "Y" ]]; then disdatacol="true"; fi
if [[ $skipwifisetup == "true" || $disdatacol == "true" ]]; then oobe="true"; else oobe="false"; fi
disautoenc="false"
read -p "Disable BitLocker automatic drive encryption [Y/N]? " bitlocker
bitlocker=${bitlocker^^}
while [[ $bitlocker != "Y" && $bitlocker != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Disable BitLocker automatic drive encryption [Y/N]? " bitlocker
bitlocker=${bitlocker^^}
done
if [[ $bitlocker == "Y" ]]; then disautoenc="true"; fi
if [[ $winmedia == "install" ]]; then
if [[ $unsupported == "false" && $localize == "false" ]]; then
mkdir -p "$windisk/sources/\$OEM\$/\$\$/Panther"
xmlpath="$windisk/sources/\$OEM\$/\$\$/Panther/unattend.xml"
else
xmlpath="$windisk/autounattend.xml"
fi
elif [[ $winmedia == "wintogo" ]]; then
mkdir "$windisk/Windows/Panther"
xmlpath="$windisk/Windows/Panther/unattend.xml"
fi
(cd $resdir/Windows/Scripts; ./unattend.sh $unsupported $localize $bypassnro $oobe $settimezone $useraccounts $skipwifisetup $disdatacol $disautoenc "$loginname" "$fullname" "$description" > "$xmlpath")
}
win11opts () {
if [[ $winmedia == "install" ]]; then
read -p "Disable TPM, Secure Boot and RAM requirements [Y/N]? " bypasshw
bypasshw=${bypasshw^^}
while [[ $bypasshw != "Y" && $bypasshw != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Disable TPM, Secure Boot and RAM requirements [Y/N]? " bypasshw
bypasshw=${bypasshw^^}
done
if [[ $bypasshw == "Y" ]]; then
if [[ $wimtools == "true" && ! -z $(command -v hivexregedit) ]]; then
(cd $resdir/Windows/Scripts; ./unsupported.sh "$windisk")
else
unsupported="true"
fi
fi
fi
read -p "Disable requirement for an online Microsoft account [Y/N]? " msaccount
msaccount=${msaccount^^}
while [[ $msaccount != "Y" && $msaccount != "N" ]]; do
echo -e "${RED}Invalid entry. Try again.${NC}"
read -p "Disable requirement for an online Microsoft account [Y/N]? " msaccount
msaccount=${msaccount^^}
done
if [[ $msaccount == "Y" ]]; then bypassnro="true"; fi
}
show_about () {
clear
cat $resdir/Support/About.txt
echo
read -n 1 -s -r -p "Press any key to continue"
}
select_err () {
echo "Invalid selection try again."
sleep 1
}
# Script starts here.
RED='\033[1;31m'
NC='\033[0m' # No Color
system=`uname`
# Set resource location for supported platforms or exit.
if [[ $system == "Darwin" ]]; then
resdir="/opt/local/share/BOOTDISK"
elif [[ $system == "Linux" ]]; then
resdir="/usr/local/share/BOOTDISK"
else
echo "Unsupported platform detected."
exit 1
fi
# Check for required packages that are missing.
if [[ $(command -v 7z) == "" ]]; then missing+=" p7zip"; fi
if [[ $(command -v jq) == "" ]]; then missing+=" jq"; fi
if [[ $(command -v curl) == "" ]]; then missing+=" curl"; fi
if [[ $system == "Linux" && $(command -v mkntfs) == "" ]]; then missing+=" ntfs-3g"; fi
if [[ $system == "Linux" && $(command -v mkfs.exfat) == "" ]]; then missing+=" exfatprogs"; fi
if [[ $system == "Darwin" ]]; then
bashver=$(bash --version | head -n 1 | awk '{print $4}' | cut -f1 -d'(')
if [ "$(printf '%s\n' "3.2.57" "$bashver" | sort -rV | head -n1)" == "3.2.57" ]; then
missing+=" bash(>$bashver)"
fi
fi
if [[ $system == "Darwin" ]] || [[ $system == "Linux" && ! -z $(command -v ms-sys) ]]; then
if [[ $(command -v mtools) == "" ]]; then
missing+=" mtools"
fi
fi
if [[ "$missing" != "" ]]; then
echo "The following packages are required:""$missing"
exit 1
fi
# Check if user is member of disk group under Linux.
if [[ $system == "Linux" && -z $(id | grep -o '(disk)') ]]; then
echo "Please add $USER to the disk group."
exit 1
fi
# Download UEFI:NTFS bootloader if missing or outdated.
uefint_url="https://raw.githubusercontent.com/pbatard/rufus/master/res/uefi/uefi-ntfs.img"
uefint_commit_url="https://api.github.com/repos/pbatard/rufus/commits?path=res/uefi/uefi-ntfs.img&page=1&per_page=1"
uefint_commit_date=$(curl -s $uefint_commit_url | jq -r '.[0].commit.committer.date' | cut -f1 -d"T")
uefint_image_date=$($resdir/Support/modtime.py $resdir/Support/uefi-ntfs.img 2> /dev/null | awk '{print $1}')
if [[ ! -e $resdir/Support/uefi-ntfs.img ]] || [[ $uefint_commit_date > $uefint_image_date ]]; then
rm -f $resdir/Support/uefi-ntfs.img 2> /dev/null
curl -o $resdir/Support/uefi-ntfs.img $uefint_url 2> /dev/null
fi
# Determine if wimlib and its tools are installed.
if [[ $(command -v wimlib-imagex) == "" ]]; then
wimtools="false"
else
wimtools="true"
fi
# Display menu for available options.
if [[ $system == "Darwin" ]] || [[ $system == "Linux" && ! -z $(command -v ms-sys) ]]; then
if [[ -e $resdir/MS-DOS/Files/COMMAND.COM ]]; then
menu_all
else
menu_standard
fi
else
menu_uefi
fi