forked from pocopico/tinycore-redpill
-
Notifications
You must be signed in to change notification settings - Fork 37
/
functions_t.sh
3496 lines (2917 loc) · 134 KB
/
functions_t.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
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
set -u # Unbound variable errors are not allowed
rploaderver="1.0.5.2"
build="master"
redpillmake="prod"
modalias4="https://raw.githubusercontent.com/PeterSuh-Q3/tinycore-redpill/$build/modules.alias.4.json.gz"
modalias3="https://raw.githubusercontent.com/PeterSuh-Q3/tinycore-redpill/$build/modules.alias.3.json.gz"
timezone="UTC"
ntpserver="pool.ntp.org"
userconfigfile="/home/tc/user_config.json"
gitdomain="raw.githubusercontent.com"
mshellgz="my.sh.gz"
mshtarfile="https://raw.githubusercontent.com/PeterSuh-Q3/tinycore-redpill/master/my.sh.gz"
#Defaults
smallfixnumber="0"
function history() {
cat <<EOF
--------------------------------------------------------------------------------------
0.7.0.0 Added build for version greater than 42218
0.7.0.1 Added required extension parsing adding and downloading
0.7.0.2 Added usb patch in patchdtc
0.7.0.3 Added portnumber on patchdtc
0.7.0.4 Make sure that local cache folder is created early in the process
0.7.0.5 Enabled interactive
0.7.0.6 Added save/restore session functions
0.7.0.7 Added a check date function
0.7.0.8 Added the ability to use local dtb file
0.7.0.9 Added flyride satamap review
0.7.1.0 Added the history, version and enhanced patchdtc function
0.7.1.1 Added a syntaxcheck function
0.7.1.2 Added sync time with NTP server : pool.ntp.org (Set timezone and ntpserver variables accordingly )
0.7.1.3 Added the option to create JUN mod loader (By Jumkey)
0.7.1.4 Added the use of the additional custom_config_jun.json for JUN mod loader creation
0.7.1.5 Updated satamap function to support higher the 9 port counts per HBA.
0.7.1.6 Updated satamap function to fix the broken q35 KVM controller, and to stop scanning for CD-ROM's
0.7.1.7 Updated serialgen function to include the option for using the realmac
0.7.1.8 Updated satamap function to fine tune SATA port identification and identify SATABOOT
0.7.1.9 Updated patchdtc function to fix wrong port identification for VMware hosted systems
0.8.0.0 Stable version. All new features will be moved to develop repo
0.8.0.0 Stable version. All new features will be moved to develop repo
0.8.0.1 Updated postupdate to facilitate update to update2
0.8.0.2 Updated satamap to support DUMMY PORT detection
0.8.0.3 Updated satamap to avoid the use of 0 in first controller that cause KP
0.9.0.0 Development version. Moving all new features to development build
0.9.0.1 Updated postupdate to facilitate update to update2
0.9.0.2 Added system monitor function
0.9.0.3 Updated satamap to support DUMMY PORT detection
0.9.0.4 More satamap fixes
0.9.0.5 Added the option to get grub variables into user_config.json
0.9.0.6 Experimental DVA1622 (geminilake) addition
0.9.0.7 Experimental DVA1622 serialgen
0.9.0.8 Experimental DVA1622 increase disk count to 16
0.9.0.9 Fixed missing bspatch
0.9.1.0 Added dtc depth patch
0.9.1.1 Default action for DTB system is to use the dtbpatch by fbelavenuto
0.9.1.2 Fixed a jq issue in listextension
0.9.1.3 Fixed bsdiff not found issue
0.9.1.4 Fixed overlaping downloadextractor processes
0.9.1.5 Enhanced postupdate process to update user_config.json to new format
0.9.1.6 Fixed compressed non-compressed RAMDISK issue
0.9.1.7 Enhanced build process to update user_config.json during build process
0.9.1.8 Enhanced build process to create friend files
0.9.1.9 Further enhanced build process
0.9.2.0 Introducing TCRP Friend
0.9.2.1 If TCRP Friend is used then default option will be TCRP Friend
0.9.2.2 Upgrade your system by adding TCRP Friend with command bringfriend
0.9.2.3 Adding experimental DS2422+ support
0.9.2.4 Added the redpillmake variable to select between prod and dev modules
0.9.2.5 Adding experimental RS4021xs+ support
0.9.2.6 Added the downloadupgradepat action **experimental
0.9.2.7 Added setting the static network configuration for TCRP Friend
0.9.2.8 Changed all calls to use the -k flag to avoid expired certificate issues
0.9.2.9 Added the smallfixnumber key in user_config.json and changed the platform ids to model ids
0.9.3.0 Changed set root entry to search for FS UUID
0.9.4.3-1 Multilingual menu support
0.9.5.0 Add storage panel size selection menu
0.9.6.0 To prevent partition space shortage, rd.gz is no longer used in partition 1
0.9.7.0 Improved build processing speed (removed pat file download process)
0.9.7.1 Back to DSM Pat Handle Method
1.0.0.0 Kernel patch process improvements
1.0.0.1 Improved platform release ID identification method
1.0.0.2 Setplatform() function converted to custom_config.json reference method
1.0.0.3 To prevent partition space shortage, custom.gz is no longer used in partition 1
1.0.0.4 Prevents kernel panic from occurring due to rp-lkm.zip download failure
when ramdisk patching occurs without internet.
1.0.0.5 Add offline loader build function
1.0.1.0 Upgrade from Tinycore version 12.0 (kernel 5.10.3) to 14.0 (kernel 6.1.2) to improve compatibility with the latest devices.
1.0.1.1 Fix monitor fuction about ethernet infomation
1.0.1.2 Fix for SA6400
1.0.2.0 Remove restrictions on use of DT-based models when using HBA (apply mpt3sas blacklist instead)
1.0.2.1 Changed extension file organization method
1.0.2.2 Recycle initrd-dsm instead of custom.gz (extract /exts), The priority starts from custom.gz
1.0.2.3 Added RedPill bootloader hard disk porting function
1.0.2.4 Added NVMe bootloader support
1.0.2.5 Provides menu option to disable i915 module loading to prevent console blackout in ApolloLake (DS918+), GeminiLake (DS920+), and Epyc7002 (SA6400)
1.0.2.6 Added multilingual support languages (locales) (Arabic, Hindi, Hungarian, Indonesian, Turkish)
1.0.2.7 dbgutils Addon Add/Delete selection menu
1.0.2.8 Added multilingual support languages (locales) (Amharic-Ethiopian, Thai)
1.0.2.9 Release img image with gettext.tgz
1.0.3.0 Integrate my, rploader.sh, myfunc.h into functions.sh, optimize distribution
1.0.3.1 Added loader file packing menu for remote update
1.0.3.2 Added dom_szmax for jot mode
1.0.3.3 Boot entry order for jot mode synchronized with Friend's order, remove custom_config_jun.json
1.0.3.4 Maintain boot-wait addon when using satadom in SA6400
1.0.3.5 Remove getstaticmodule() and undefined PROXY variables (cause of lkm download failure in final release)
1.0.3.6 Use intel_iommu on the command line
1.0.3.7 Add command line native satadom support option change menu
1.0.3.8 Sort netif order by bus-id order (Synology netif sorting method)
1.0.3.9 NVMe-related function supplementation and error correction
Discontinue use of sortnetif addon, discontinue use of sortnetif if there is only 1 NIC
1.0.4.0 Added sata_remap processing menu for SataPort reordering.
1.0.4.1 Added a feature to check whether the pre-counted number of disks matches when booting Friend
1.0.4.2 Add Support DSM 7.2.2-72803 Official Version
1.0.4.3 No separation between USB/SATA menus in Jot Mod (boot menu merge)
1.0.4.4 Loader building is blocked when using Apollolake + proxmox(kvm)/qemu(kvm) (KP occurs in versions after lkm 24.8.29)
1.0.4.5 Solved the KP occurrence issue when using SATA-type bootloader in proxmox(kvm),
SA6400(epyc7002) integration from lkm5 (lkm 24.9.8)
1.0.4.6 Rearrange menu order, automatically enter Gen value when S/N or mac is not selected
1.0.4.7 Fix from DSM 7.2.2-72803 to DSM 7.2.2-72806
1.0.4.8 Enable mmc (SD Card) bus type recognition for the bootloader
1.0.4.9 When mmc bus type is used, module processing method is applied with priority given to eudev instead of ddsml.
1.0.5.0 Improved internet check function in menu.sh
1.0.5.1 Added manual update feature to friend specified version, added disable/enable friend automatic update feature
1.0.5.2 Upgraded grub version from 2.06 to 2.12 ( improved uefi, legacy boot compatibility [especially in jot mode] )
--------------------------------------------------------------------------------------
EOF
}
# Made by Peter Suh
# 2022.04.18
# Update add 42661 U1 NanoPacked
# 2022.04.28
# Update : add noconfig, noclean, manual options
# 2022.04.30
# Update : add noconfig, noclean, manual combinatione options
# 2022.05.06
# Update : add pat file sha256 check
# 2022.05.07
# Update : Added dtc compilation function for user custom.dts file
# 2022.05.15
# Update : add jumkey's jun mode
# 2022.05.24
# Update : apply jumkey's dyn dtc upx
# 2022.05.25
# Update : apply jumkey's dyn dtc upx for option
# 2022.06.01
# Update : add rd.gz patch for 42661 U2
# 2022.06.03
# Update : Fixed Jun mode build option incorrectly applied
# 2022.06.06
# Update : Add jumkey's Jun mode (use jumkey repo)
# 2022.06.11
# Update : Adjunst Option Operation
# 2022.06.13
# Update : Add manual option for jun mode
# 2022.06.16
# Update : Add dtc mode for known as non-dtc model
# 2022.06.25
# Update : Add dtc model DS2422+ (v1000) support
# 2022.06.27
# Update : remove jumkey, poco oprtions
# 2022.06.30
# Update : Add DS2422+ jot mode
# 2022.07.02
# Update : Add DVA1622 jun mode (Testing)
# 2022.07.07
# Update : Add DS1520+ jun mode
# 2022.07.08
# Update : Add FS2500 jun mode
# 2022.07.10
# Update : function headers for my.sh and myv.shUse common function headers for my.sh and myv.sh
# 2022.07.11
# Update : Add REALMAC Option
# 2022.07.15
# Update : Add DS1621xs+ jun mode
# 2022.07.19
# Update : Add DS1621xs+ jot mode, Add RS4021xs+
# 2022.07.20
# Update : Add DVA3219 jot mode (Release 22.07.25)
# 2022.07.21
# Update : Active rploader satamap for non dtc model
# 2022.07.27
# Update : Add Re-Install DSM menuentry
# 2022.08.03
# Update : Apply fabio's redpill.ko
# 2022.08.04
# Update : Add Userdts Options
# 2022.08.06
# Update : Release FS2500 Jot / Jun Mode
# 2022.08.12
# Update : Add RS3618xs Jot / Jun Mode
# 2022.08.14
# Update : Add RS3413xs+ Jot / Jun Mode
# 2022.08.16
# Update : Added support for DSM 7.1.1-42962
# 2022.09.13
# Update : Add DS1019+ Jot / Jun Mode
# 2022.09.14
# Update : Release DS1520+ jot mode
# 2022.09.14
# Update : Release DVA3219 jun mode
# 2022.09.14
# Update : Sataportmap,DiskIdxMap to blank for VM with noconfig option
# 2022.09.14
# Update : Release TCRP FRIEND mode
# 2022.09.25
# Update : Change to stable redpill kernel ( DS1621xs+, DVA3221, RS3618xs )
# 2022.09.26
# Update : Synchronization according to the TCRP Platform naming convention
# 2022.10.22
# Update : Dropped support for TCRP Jot's Mod /Jun's Mod.
# 2022.11.11
# Update : Deploy menu.sh
# 2022.11.14
# Update : Added autoupdate script, Added Keymap function to menu.sh for multilingual keybaord support
# 2022.11.17
# Update : Added dual mac address make function to menu.sh
# 2022.11.18
# Update : Added ds923+ (r1000)
# 2022.11.25
# Update : Added gitee conversion function when github connection is not possible
# 2022.12.03
# Update : Added quad mac address make function to menu.sh
# 2022.12.04
# Update : Added independent JOT mode build menu to menu.sh
# 2022.12.06
# Correct serial number for DS1520+,DS923+, by Orphee
# 2022.12.13
# Update : Added ds723+ (r1000)
# 2023.01.15
# Update : Add buildable model limit per CPU max threads to menu.sh, add description of features and restrictions for each model
# 2023.01.28
# Update : DT-based model restriction function added to ./menu.sh
# 2023.01.30
# Update : Separation and addition to menu_m.sh for real-time reflection after menu.sh update
# 2023.01.30
# Update : 7.0.1-42218 friend correspondence for DS918+,DS920+,DS1019+, DS1520+ transcoding
# 2023.02.19
# Update : Inspection of FMA3 command support (Haswell or higher) and model restriction function added to menu.sh
# 2023.02.22
# Update : menu.sh Added new function DDSML / EUDEV selection
# DDSML ( Detected Device Static Module Loading with modprobe / insmod command )
# EUDEV (Enhanced Userspace Device with eudev deamon)
# 2023.03.01
# Update : Added erase data disk function to menu.sh
# 2023.03.04
# Update : Increased build processing speed by using RAMDISK & pigz(multithreaded compression) when processing encrypted DSM PAT file decryption
# 2023.03.10
# Update : Improved TCRP loader build process
# 2023.03.14
# Update : Automatic handling of grub.cfg disable_mtrr_trim=1 to unlock AMD Platform 3.5GB RAM limitation
# 2023.03.17
# Update : AMD CPU FRIEND mode menu usage restriction release (except HP N36L/N40L/N54L)
# 2023.03.18
# Update : TCRP FRIEND / JOT menu selection method improvement
# 2023.03.21
# Update : Multilingual menu support started (Korean, Chinese, Japanese, Russian, French, German, Spanish, Brazilian, Italian supported)
# 2023.03.25
# Update : Add language selection menu
# 2023.03.29
# Update : Merging DDSML and EUDEV into one, Improved nic recognition speed by improving realtek firmware omission
# 2023.04.04
# Update : DSM Smallupdateversion Path Management
# 2023.04.15
# Update : Keymap now actually works. (Thanks Orphée)
# 2023.04.29
# Update : Add Postupdate boot entry to Grub Boot for Jot Postupdate to utilize FRIEND's Ramdisk Update
# 2023.05.01
# Update : Add Support DSM 7.2-64551 RC
# 2023.05.02
# Update : Added sa6400 (epyc7002)
# 2023.05.06
# Update : Add 5 models DS720+,RS1221+,RS1619xs+,RS3621xs+,SA3400
# 2023.05.08
# Update : 7.0.1-42218 menu open for all models
# 2023.05.12
# Update : Add Support DSM 7.2-64561 Official Version
# 2023.05.23
# Update : Add Getty Console to DSM 7.2
# 2023.05.26
# Update : Added ds916+ (braswell), 7.2.0 Jot Menu Creation for HP PCs
# 2023.06.03
# Update : Add Support DSM 7.2-64570 Official Version
# 2023.06.17
# Update : Added ds1821+ (v1000)
# 2023.06.18
# Update : Added ds1823xs+ (v1000), ds620slim (apollokale), ds1819+ (denverton)
# 2023.06.20
# Update : Add Support DSM 7.2-64570-1 Official Version
# 2023.07.07
# Update : Fix Bug for userdts option
# 2023.08.24 (M-SHELL for TCRP, v0.9.5.0 release)
# Update : Add storage panel size selection menu
# 2023.08.29
# Update : Added a function to store loader.img for DSM 7.2 for 7.2 automatic loader build of 7.0.1, 7.1.1
# 2023.09.26
# Update : Add Support DSM 7.2.1-69057 Official Version
# 2023.09.30
# Update : Fixed locale selection issue, modified some menu guidance text
# 2023.10.01
# Update : Add "Show SATA(s) # ports and drives" menu
# 2023.10.07
# Update : Add "Burn Anither TCRP Bootloader to USB or SSD" menu
# 2023.10.09
# Update : Add "Clone TCRP Bootloader to USB or SSD" menu
# 2023.10.17
# Update : Add "Show error log of running loader" menu
# 2023.10.18 v0.9.6.0
# Update : Improved extension processing speed (local copy instead of remote curl download)
# 2023.10.22 v0.9.7.0
# Update : Improved build processing speed (removed pat file download process)
# 2023.10.24 v0.9.7.1
# Update : Back to DSM Pat Handle Method
# 2023.10.27 v1.0.0.0
# Update : Kernel patch process improvements
# 2023.11.04
# Update : Added DS1522+ (r1000), DS220+ (geminilake), DS2419+ (denverton), DS423+ (geminilake), DS718+ (apollolake), RS2423+ (v1000)
# 2023.11.28
# Update : Turn off thread limits when displaying models (Thanks alirz1)
# 2023.12.01
# Update : Separate tcrp-addons and tcrp-modules repo processing methods
# 2023.12.02
# Update : Add offline loader build function
# 2023.12.18 v1.0.1.0
# Update : Upgrade from Tinycore version 12.0 (kernel 5.10.3) to 14.0 (kernel 6.1.2) to improve compatibility with the latest devices.
# 2023.12.31
# Added SataPortMap/DiskIdxMap prevent initialization menu for virtual machines
# 2024.02.03
# Created a menu to select the mac-spoof add-on and a submenu for additional features.
# 2024.02.06
# update corepure64.gz for tc user ttyS0 serial console works
# 2024.02.08
# Add Apollolake DS218+
# 2024.02.22 v1.0.2.0
# Remove restrictions on use of DT-based models when using HBA (apply mpt3sas blacklist instead)
# 2024.03.06 v1.0.2.2
# Recycle initrd-dsm instead of custom.gz (extract /exts)
# 2024.03.13 v1.0.2.3
# Added RedPill bootloader hard disk porting function
# 2024.03.15
# Added RedPill bootloader hard disk porting function supporting 1 SHR Type DISK
# 2024.03.18
# Added RedPill bootloader hard disk porting function supporting All SHR & RAID Type DISK
# 2024.03.22 v1.0.2.4
# Added NVMe bootloader support
# 2024.03.23
# Fixed bug where both modules disappear when switching between ddsml and eudev (Causes NIC unresponsiveness)
# 2024.03.24
# Added missing mmc partition search function
# 2024.04.01 v1.0.2.5
# Provides menu option to disable i915 module loading to prevent console blackout in ApolloLake (DS918+), GeminiLake (DS920+), and Epyc7002 (SA6400)
# 2024.04.09 v1.0.2.6
# Added multilingual support languages (locales) (Arabic, Hindi, Hungarian, Indonesian, Turkish)
# 2024.04.09 v1.0.2.7
# dbgutils Addon Add/Delete selection menu
# 2024.04.14
# sortnetif Addon Add/Delete selection menu
# 2024.05.08 v1.0.2.8
# Added multilingual support languages (locales) (Amharic-Ethiopian, Thai)
# 2024.05.13
# Menu configuration for adding nvmesystem addon
# 2024.05.26 v1.0.3.0
# Integrate my, rploader.sh, myfunc.h into functions.sh, optimize distribution
# 2024.06.01 v1.0.3.1, 1.0.3.2
# Added loader file packing menu for remote update, Added dom_szmax for jot mode
# 2024.06.04 v1.0.3.3
# Boot entry order for jot mode synchronized with Friend's order
# 2024.06.08 v1.0.3.4
# Maintain boot-wait addon when using satadom in SA6400
# 2024.06.09 v1.0.3.5
# Remove getstaticmodule() and undefined PROXY variables (cause of lkm download failure in final release)
# 2024.06.10 v1.0.3.6
# Use intel_iommu on the command line
# 2024.06.11 v1.0.3.7
# Add command line native satadom support option change menu
# 2024.06.17 v1.0.3.8
# Sort netif order by bus-id order (Synology netif sorting method)
# 2024.07.06 v1.0.3.9
# NVMe-related function supplementation and error correction
# Discontinue use of sortnetif addon, discontinue use of sortnetif if there is only 1 NIC
# 2024.07.07 v1.0.4.0
# Added sata_remap processing menu for SataPort reordering.
# 2024.08.23 v1.0.4.1
# Added a feature to check whether the pre-counted number of disks matches when booting Friend
# 2024.08.26 v1.0.4.2
# Update : Add Support DSM 7.2.2-72803 Official Version
# 2024.08.31 v1.0.4.3
# No separation between USB/SATA menus in Jot Mod (boot menu merge)
# 2024.09.05 v1.0.4.4
# Loader building is blocked when using Apollolake + proxmox(kvm)/qemu(kvm) (KP occurs in versions after lkm 24.8.29)
# 2024.09.08 v1.0.4.5
# Solved the KP occurrence issue when using SATA-type bootloader in proxmox(kvm),
# SA6400(epyc7002) integration from lkm5 (lkm 24.9.8)
# 2024.09.09 v1.0.4.6
# Rearrange menu order, automatically enter Gen value when S/N or mac is not selected
# 2024.09.12 v1.0.4.7
# Fix from DSM 7.2.2-72803 to DSM 7.2.2-72806
# 2024.10.14 v1.0.4.8
# Enable mmc (SD Card) bus type recognition for the bootloader
# 2024.10.15 v1.0.4.9
# When mmc bus type is used, module processing method is applied with priority given to eudev instead of ddsml.
# 2024.10.26 v1.0.5.0
# Improved internet check function in menu.sh
# 2024.11.04 v1.0.5.1
# Added manual update feature to friend specified version, added disable/enable friend automatic update feature
# 2024.11.05 v1.0.5.2
# Upgraded grub version from 2.06 to 2.12 ( improved uefi, legacy boot compatibility [especially in jot mode] )
function showlastupdate() {
cat <<EOF
# 2023.12.18 v1.0.1.0
# Update : Upgrade from Tinycore version 12.0 (kernel 5.10.3) to 14.0 (kernel 6.1.2) to improve compatibility with the latest devices.
# 2024.03.18
# Added RedPill bootloader hard disk porting function supporting All SHR & RAID Type DISK
# 2024.03.22 v1.0.2.4
# Added NVMe bootloader support
# 2024.05.13
# Menu configuration for adding nvmesystem addon
# 2024.05.26 v1.0.3.0
# Integrate my, rploader.sh, myfunc.h into functions.sh, optimize distribution
# 2024.06.01 v1.0.3.1, 1.0.3.2
# Added loader file packing menu for remote update, Added dom_szmax for jot mode
# 2024.06.04 v1.0.3.3
# Boot entry order for jot mode synchronized with Friend's order
# 2024.06.08 v1.0.3.4
# Maintain boot-wait addon when using satadom in SA6400
# 2024.06.09 v1.0.3.5
# Remove getstaticmodule() and undefined PROXY variables (cause of lkm download failure in final release)
# 2024.06.10 v1.0.3.6
# Use intel_iommu on the command line
# 2024.06.11 v1.0.3.7
#Add command line native satadom support option change menu
# 2024.06.17 v1.0.3.8
# Sort netif order by bus-id order (Synology netif sorting method)
# 2024.07.06 v1.0.3.9
# NVMe-related function supplementation and error correction
# Discontinue use of sortnetif addon, discontinue use of sortnetif if there is only 1 NIC
# 2024.07.07 v1.0.4.0
# Added sata_remap processing menu for SataPort reordering.
# 2024.08.23 v1.0.4.1
# Added a feature to check whether the pre-counted number of disks matches when booting Friend
# 2024.08.26 v1.0.4.2
# Update : Add Support DSM 7.2.2-72803 Official Version
# 2024.08.31 v1.0.4.3
# No separation between USB/SATA menus in Jot Mod (boot menu merge)
# 2024.09.05 v1.0.4.4
# Loader building is blocked when using Apollolake + proxmox(kvm)/qemu(kvm) (KP occurs in versions after lkm 24.8.29)
# 2024.09.08 v1.0.4.5
# Solved the KP occurrence issue when using SATA-type bootloader in proxmox(kvm),
# SA6400(epyc7002) integration from lkm5 (lkm 24.9.8)
# 2024.09.09 v1.0.4.6
# Rearrange menu order, automatically enter Gen value when S/N or mac is not selected
# 2024.09.12 v1.0.4.7
# Fix from DSM 7.2.2-72803 to DSM 7.2.2-72806
# 2024.10.14 v1.0.4.8
# Enable mmc (SD Card) bus type recognition for the bootloader
# 2024.10.15 v1.0.4.9
# When mmc bus type is used, module processing method is applied with priority given to eudev instead of ddsml.
# 2024.10.26 v1.0.5.0
# Improved internet check function in menu.sh
# 2024.11.04 v1.0.5.1
# Added manual update feature to friend specified version, added disable/enable friend automatic update feature
# ( usage : ./functions.sh update v0.1.1j | ./functions.sh autoupdate off | ./functions.sh autoupdate on )
# 2024.11.05 v1.0.5.2
# Upgraded grub version from 2.06 to 2.12 ( improved uefi, legacy boot compatibility [especially in jot mode] )
EOF
}
function showhelp() {
cat <<EOF
$(basename ${0})
----------------------------------------------------------------------------------------
Usage: ${0} <Synology Model Name> <Options>
Options: update, postupdate, noconfig, noclean, manual, realmac, userdts
- update : Option to handle updates to the m shell.
- postupdate : Option to patch the restore loop after applying DSM 7.1.0-42661 after Update 2, no additional build required.
- noconfig: SKIP automatic detection change processing such as SN/Mac/Vid/Pid/SataPortMap of user_config.json file.
- noclean: SKIP the 💊 RedPill LKM/LOAD directory without clearing it with the Clean command.
However, delete the Cache directory and loader.img.
- manual: Options for manual extension processing and manual dtc processing in build action (skipping extension auto detection).
- realmac : Option to use the NIC's real mac address instead of creating a virtual one.
- userdts : Option to use the user-defined platform.dts file instead of auto-discovery mapping with dtcpatch.
Please type Synology Model Name after ./$(basename ${0})
- for friend mode
./$(basename ${0}) DS918+-7.2.1-69057
./$(basename ${0}) DS3617xs-7.2.1-69057
./$(basename ${0}) DS3615xs-7.2.1-69057
./$(basename ${0}) DS3622xs+-7.2.1-69057
./$(basename ${0}) DVA3221-7.2.1-69057
./$(basename ${0}) DS920+-7.2.1-69057
./$(basename ${0}) DS1621+-7.2.1-69057
./$(basename ${0}) DS2422+-7.2.1-69057
./$(basename ${0}) DVA1622-7.2.1-69057
./$(basename ${0}) DS1520+-7.2.1-69057
./$(basename ${0}) FS2500-7.2.1-69057
./$(basename ${0}) DS1621xs+-7.2.1-69057
./$(basename ${0}) RS4021xs+-7.2.1-69057
./$(basename ${0}) DVA3219-7.2.1-69057
./$(basename ${0}) RS3618xs-7.2.1-69057
./$(basename ${0}) DS1019+-7.2.1-69057
./$(basename ${0}) DS923+-7.2.1-69057
./$(basename ${0}) DS723+-7.2.1-69057
./$(basename ${0}) SA6400-7.2.1-69057
./$(basename ${0}) DS720+-7.2.1-69057
./$(basename ${0}) RS1221+-7.2.1-69057
./$(basename ${0}) RS2423+-7.2.1-69057
./$(basename ${0}) RS1619xs+-7.2.1-69057
./$(basename ${0}) RS3621xs+-7.2.1-69057
./$(basename ${0}) SA6400-7.2.1-69057
./$(basename ${0}) DS916+-7.2.1-69057
./$(basename ${0}) DS1821+-7.2.1-69057
./$(basename ${0}) DS1819+-7.2.1-69057
./$(basename ${0}) DS1823xs+-7.2.1-69057
./$(basename ${0}) DS620slim+-7.2.1-69057
ex) Except for postupdate and userdts that must be used alone, the rest of the options can be used in combination.
- When you want to build the loader while maintaining the already set SN/Mac/Vid/Pid/SataPortMap
./my DS3622xs+H noconfig
- When you want to build the loader while maintaining the already set SN/Mac/Vid/Pid/SataPortMap and without deleting the downloaded DSM pat file.
./my DS3622xs+H noconfig noclean
- When you want to build the loader while using the real MAC address of the NIC, with extended auto-detection disabled
./my DS3622xs+H realmac manual
EOF
}
function getloaderdisk() {
loaderdisk=""
for edisk in $(sudo fdisk -l | grep "Disk /dev/sd" | awk '{print $2}' | sed 's/://' ); do
if [ $(sudo fdisk -l | grep "83 Linux" | grep ${edisk} | wc -l ) -eq 3 ]; then
loaderdisk="$(blkid | grep ${edisk} | grep "6234-C863" | cut -c 1-8 | awk -F\/ '{print $3}')"
fi
done
if [ -z "${loaderdisk}" ]; then
for edisk in $(sudo fdisk -l | grep -e "Disk /dev/nvme" -e "Disk /dev/mmc" | awk '{print $2}' | sed 's/://' ); do
if [ $(sudo fdisk -l | grep "83 Linux" | grep ${edisk} | wc -l ) -eq 3 ]; then
loaderdisk="$(blkid | grep ${edisk} | grep "6234-C863" | cut -c 1-12 | awk -F\/ '{print $3}')"
fi
done
fi
if [ -z "${loaderdisk}" ]; then
for edisk in $(sudo fdisk -l | grep "Disk /dev/loop" | awk '{print $2}' | sed 's/://' ); do
if [ $(sudo fdisk -l | grep "83 Linux" | grep ${edisk} | wc -l ) -eq 3 ]; then
loaderdisk="$(echo ${edisk} | cut -c 1-12 | awk -F\/ '{print $3}')"
fi
done
fi
}
# ==============================================================================
# Color Function
# ==============================================================================
function cecho () {
# if [ -n "$3" ]
# then
# case "$3" in
# black | bk) bgcolor="40";;
# red | r) bgcolor="41";;
# green | g) bgcolor="42";;
# yellow | y) bgcolor="43";;
# blue | b) bgcolor="44";;
# purple | p) bgcolor="45";;
# cyan | c) bgcolor="46";;
# gray | gr) bgcolor="47";;
# esac
# else
bgcolor="0"
# fi
code="\033["
case "$1" in
black | bk) color="${code}${bgcolor};30m";;
red | r) color="${code}${bgcolor};31m";;
green | g) color="${code}${bgcolor};32m";;
yellow | y) color="${code}${bgcolor};33m";;
blue | b) color="${code}${bgcolor};34m";;
purple | p) color="${code}${bgcolor};35m";;
cyan | c) color="${code}${bgcolor};36m";;
gray | gr) color="${code}${bgcolor};37m";;
esac
text="$color$2${code}0m"
echo -e "$text"
}
function getvarsmshell()
{
SUVP=""
ORIGIN_PLATFORM=""
tem="${1}"
MODEL="$(echo ${tem} |cut -d '-' -f 1)"
TARGET_REVISION="$(echo ${tem} |cut -d '-' -f 3)"
if [ "$TARGET_REVISION" == "64570" ]; then
TARGET_VERSION="$(echo ${tem} |cut -d '-' -f 2 | cut -c 1-3)"
else
TARGET_VERSION="$(echo ${tem} |cut -d '-' -f 2)"
fi
#echo "MODEL is $MODEL"
TARGET_PLATFORM=$(echo "$MODEL" | sed 's/DS/ds/' | sed 's/RS/rs/' | sed 's/+/p/' | sed 's/DVA/dva/' | sed 's/FS/fs/' | sed 's/SA/sa/' )
SYNOMODEL="${TARGET_PLATFORM}_${TARGET_REVISION}"
MODELS="DS3615xs DS218+ DS1019+ DS620slim DS1520+ DS1522+ DS220+ DS2419+ DS423+ DS718+ DS1621+ DS1821+ DS1823xs+ DS1621xs+ DS2422+ DS3617xs DS3622xs+ DS720+ DS723+ DS918+ DS920+ DS923+ DS1819+ DVA3219 DVA3221 DVA1622 FS2500 RS1221+ RS1619xs+ RS2423+ RS3413xs+ RS3618xs RS3621xs+ RS4021xs+ SA3410 SA3610 SA6400"
if [ $(echo ${MODELS} | grep ${MODEL} | wc -l ) -eq 0 ]; then
echo "This synology model not supported by TCRP."
exit 99
fi
if [ "$TARGET_REVISION" == "42218" ]; then
KVER="4.4.180"
SUVP=""
elif [ "$TARGET_REVISION" == "42962" ]; then
KVER="4.4.180"
MODELS6="DS423+ DS723+ DS923+ DS1823xs+ RS3621xs+ RS4021xs+ RS3618xs SA6400"
if [ $(echo ${MODELS6} | grep ${MODEL} | wc -l ) -gt 0 ]; then
SUVP="-6"
else
SUVP="-1"
fi
elif [ "$TARGET_REVISION" == "64570" ]; then
KVER="4.4.302"
SUVP="-1"
elif [ "$TARGET_REVISION" == "69057" ]; then
KVER="4.4.302"
SUVP=""
if [ "${MODEL}" = "DS218+" ]; then
SUVP="-1"
fi
elif [ "$TARGET_REVISION" == "72806" ]; then
KVER="4.4.302"
SUVP=""
else
echo "Synology model revision not supported by TCRP."
exit 0
fi
case ${MODEL} in
DS218+ | DS718+ | DS918+ | DS1019+ | DS620slim )
ORIGIN_PLATFORM="apollolake"
;;
DS3615xs | RS3413xs+ )
ORIGIN_PLATFORM="bromolow"
KVER="3.10.108"
;;
DS3617xs | RS3618xs )
ORIGIN_PLATFORM="broadwell"
;;
DS3622xs+ | DS1621xs+ | SA3400 | SA3600 | RS1619xs+ | RS3621xs+ | RS4021xs+ )
ORIGIN_PLATFORM="broadwellnk"
;;
SA3410 | SA3610 )
ORIGIN_PLATFORM="broadwellnkv2"
;;
DVA3221 | DVA3219 | DS1819+ | DS2419+ )
ORIGIN_PLATFORM="denverton"
;;
DVA1622 | DS220+ | DS423+ | DS920+ | DS1520+ | DS720+ )
ORIGIN_PLATFORM="geminilake"
;;
DS923+ | DS723+ | DS1522+ )
ORIGIN_PLATFORM="r1000"
;;
DS1621+ | DS1821+ | DS1823xs+ | DS2422+ | FS2500 | RS1221+ | RS2423+ )
ORIGIN_PLATFORM="v1000"
;;
SA6400 )
ORIGIN_PLATFORM="epyc7002"
KVER="5.10.55"
;;
esac
case ${MODEL} in
DS1019+)
permanent="PDN"
serialstart="1780 1790 1860 1980"
suffix="numeric"
;;
DS1520+)
permanent="TRR"
serialstart="2270"
suffix="alpha"
;;
DS1522+)
permanent="TRR"
serialstart="2270"
suffix="alpha"
;;
DS1621+)
permanent="S7R"
serialstart="2080"
suffix="alpha"
;;
DS1621xs+)
permanent="S7R"
serialstart="2080"
suffix="alpha"
;;
DS1819+)
permanent="RFR"
serialstart="1930 1940"
suffix="alpha"
;;
DS1821+)
permanent="S7R"
serialstart="2080"
suffix="alpha"
;;
DS1823xs+)
permanent="V5R"
serialstart="22B0"
suffix="alpha"
;;
DS220+)
permanent="XXX"
serialstart="0000"
suffix="alpha"
;;
DS2419+)
permanent="QZA"
serialstart="1880"
suffix="alpha"
;;
DS2422+)
permanent="S7R"
serialstart="2080"
suffix="alpha"
;;
DS3615xs)
permanent="LWN"
serialstart="1130 1230 1330 1430"
suffix="numeric"
;;
DS3617xs)
permanent="ODN"
serialstart="1130 1230 1330 1430"
suffix="numeric"
;;
DS3622xs+)
permanent="SQR"
serialstart="2030 2040 20C0 2150"
suffix="alpha"
;;
DS423+)
permanent="VKR"
serialstart="22A0"
suffix="alpha"
;;
DS218+)
permanent="PDN"
serialstart="1780 1790 1860 1980"
suffix="numeric"
;;
DS620slim)
permanent="PDN"
serialstart="1780 1790 1860 1980"
suffix="numeric"
;;
DS718+)
permanent="PEN"
serialstart="1930"
suffix="numeric"
;;
DS720+)
permanent="SBR"
serialstart="2030 2040 20C0 2150"
suffix="alpha"
;;
DS723+)
permanent="TQR"
serialstart="2270"
suffix="alpha"
;;
DS916+)
permanent="NZN"
serialstart="1130 1230 1330 1430"
suffix="numeric"
;;
DS918+)
permanent="PDN"
serialstart="1780 1790 1860 1980"
suffix="numeric"
;;
DS920+)
permanent="SBR"
serialstart="2030 2040 20C0 2150"
suffix="alpha"
;;
DS923+)
permanent="TQR"
serialstart="2270"
suffix="alpha"
;;
DVA1622)
permanent="UBR"
serialstart="2030 2040 20C0 2150"
suffix="alpha"
;;
DVA3219)
permanent="RFR"
serialstart="1930 1940"
suffix="alpha"
;;
DVA3221)
permanent="SJR"
serialstart="2030 2040 20C0 2150"
suffix="alpha"
;;
FS2500)
permanent="PSN"
serialstart="1960"
suffix="numeric"
;;
FS6400)
permanent="PSN"
serialstart="1960"
suffix="numeric"
;;
RS1221+)
permanent="RWR"
serialstart="20B0"
suffix="alpha"
;;
RS2423+)
permanent="XXX"
serialstart="0000"
suffix="alpha"
;;
RS1619xs+)
permanent="QPR"
serialstart="1920"
suffix="alpha"
;;
RS3413xs+)
permanent="S7R"
serialstart="2080"
suffix="alpha"
;;
RS3618xs)
permanent="ODN"
serialstart="1130 1230 1330 1430"
suffix="numeric"
;;
RS3621xs+)
permanent="SZR"
serialstart="20A0"
suffix="alpha"
;;
RS4021xs+)
permanent="T2R"
serialstart="2250"
suffix="alpha"
;;
SA3400)
permanent="RJR"
serialstart="1920"
suffix="alpha"
;;
SA3600)
permanent="RJR"
serialstart="1920"
suffix="alpha"
;;
SA6400)
permanent="TQR"
serialstart="2270"
suffix="alpha"
;;
*)
permanent="XXX"
serialstart="0000"
suffix="alpha"
;;
esac
}
# Function READ_YN, cecho
# Made by FOXBI
# 2022.04.14
#
# ==============================================================================
# Y or N Function
# ==============================================================================
function READ_YN () { # ${1}:question ${2}:default
while true; do
read -n1 -p "${1}" Y_N
case "$Y_N" in
[Yy]* ) Y_N="y"
echo -e "\n"; break ;;
[Nn]* ) Y_N="n"
echo -e "\n"; break ;;
*) echo -e "Please answer in Y / y or N / n.\n" ;;
esac
done
}
function st() {
echo -e "[$(date '+%T.%3N')]:-------------------------------------------------------------" >> /home/tc/buildstatus
echo -e "\e[35m$1\e[0m \e[36m$2\e[0m $3" >> /home/tc/buildstatus
}
function getlatestmshell() {
echo -n "Checking if a newer mshell version exists on the repo -> "
if [ ! -f $mshellgz ]; then
curl -ksL "$mshtarfile" -o $mshellgz
fi
curl -ksL "$mshtarfile" -o latest.mshell.gz
CURRENTSHA="$(sha256sum $mshellgz | awk '{print $1}')"
REPOSHA="$(sha256sum latest.mshell.gz | awk '{print $1}')"
if [ "${CURRENTSHA}" != "${REPOSHA}" ]; then
if [ "${1}" = "noask" ]; then
confirmation="y"
else
echo -n "There is a newer version of m shell script on the repo should we use that ? [yY/nN]"
read confirmation
fi
if [ "$confirmation" = "y" ] || [ "$confirmation" = "Y" ]; then
echo "OK, updating, please re-run after updating"
cp -f /home/tc/latest.mshell.gz /home/tc/$mshellgz
rm -f /home/tc/latest.mshell.gz
tar -zxvf $mshellgz
echo "Updating m shell with latest updates"
. /home/tc/functions.sh
showlastupdate
echo "y"|rploader backup
echo "press any key to continue..."
read answer
else
rm -f /home/tc/latest.mshell.gz
fi
else
echo "Version is current"
rm -f /home/tc/latest.mshell.gz
fi
}