forked from pocopico/tinycore-redpill
-
Notifications
You must be signed in to change notification settings - Fork 37
/
menu_m.sh
executable file
·2239 lines (1926 loc) · 84.3 KB
/
menu_m.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
##### INCLUDES #####################################################################################################
. /home/tc/functions.sh
. /home/tc/i18n.h
#####################################################################################################
# Function to be called on Ctrl+C or ESC
function ctrl_c() {
echo ", Ctrl+C key pressed. Press Enter to return menu..."
}
function readanswer() {
while true; do
read answ
case $answ in
[Yy]* ) answer="$answ"; break;;
[Nn]* ) answer="$answ"; break;;
* ) echo "Please answer yY/nN.";;
esac
done
}
function restart() {
echo "A reboot is required. Press any key to reboot..."
read answer
clear
sudo reboot
}
function restartx() {
echo "X window needs to be restarted. Press any key to restart x window..."
read answer
clear
{ kill $(cat /tmp/.X${DISPLAY:1:1}-lock) ; sleep 2 >/dev/tty0 ; startx >/dev/tty0 ; } &
}
function installtcz() {
tczpack="${1}"
cd /mnt/${tcrppart}/cde/optional
sudo curl -kLO# http://tinycorelinux.net/12.x/x86_64/tcz/${tczpack}
sudo md5sum ${tczpack} > ${tczpack}.md5.txt
echo "${tczpack}" >> /mnt/${tcrppart}/cde/onboot.lst
cd ~
}
function restoresession() {
lastsessiondir="/mnt/${tcrppart}/lastsession"
if [ -d $lastsessiondir ]; then
echo "Found last user session, restoring session..."
if [ -d $lastsessiondir ] && [ -f ${lastsessiondir}/user_config.json ]; then
echo "Copying last stored user_config.json"
cp -f ${lastsessiondir}/user_config.json /home/tc
fi
else
echo "There is no last session stored!!!"
fi
}
function update_tinycore() {
echo "check update for tinycore 14.0..."
cd /mnt/${tcrppart}
md5_corepure64=$(sudo md5sum corepure64.gz | awk '{print $1}')
md5_vmlinuz64=$(sudo md5sum vmlinuz64 | awk '{print $1}')
if [ ${md5_corepure64} != "f33c4560e3909a7784c0e83ce424ff5c" ] || [ ${md5_vmlinuz64} != "04cb17bbf7fbca9aaaa2e1356a936d7c" ]; then
echo "current tinycore version is not 14.0, update tinycore linux to 14.0..."
sudo curl -kL# https://raw.githubusercontent.com/PeterSuh-Q3/tinycore-redpill/master/tinycore_14.0/corepure64.gz -o corepure64.gz_copy
sudo curl -kL# https://raw.githubusercontent.com/PeterSuh-Q3/tinycore-redpill/master/tinycore_14.0/vmlinuz64 -o vmlinuz64_copy
md5_corepure64=$(sudo md5sum corepure64.gz_copy | awk '{print $1}')
md5_vmlinuz64=$(sudo md5sum vmlinuz64_copy | awk '{print $1}')
if [ ${md5_corepure64} = "f33c4560e3909a7784c0e83ce424ff5c" ] && [ ${md5_vmlinuz64} = "04cb17bbf7fbca9aaaa2e1356a936d7c" ]; then
echo "tinycore 14.0 md5 check is OK! ( corepure64.gz / vmlinuz64 ) "
sudo mv corepure64.gz_copy corepure64.gz
sudo mv vmlinuz64_copy vmlinuz64
sudo curl -kL# https://raw.githubusercontent.com/PeterSuh-Q3/tinycore-redpill/master/tinycore_14.0/etc/shadow -o /etc/shadow
echo "/etc/shadow" >> /opt/.filetool.lst
cd ~
echo 'Y'|rploader backup
restart
fi
fi
cd ~
}
if [ -f /home/tc/my.sh ]; then
rm /home/tc/my.sh
fi
if [ -f /home/tc/myv.sh ]; then
rm /home/tc/myv.sh
fi
# Prevent SataPortMap/DiskIdxMap initialization 2023.12.31
prevent_init="OFF"
# Trap Ctrl+C (SIGINT) signals and call ctrl_c function
trap ctrl_c INT
VERSION=v`cat /home/tc/functions.sh | grep rploaderver= | cut -d\" -f2`
getloaderdisk
if [ -z "${loaderdisk}" ]; then
echo "Not Supported Loader BUS Type, program Exit!!!"
echo "press any key to continue..."
read answer
exit 99
fi
getBus "${loaderdisk}"
[ "${BUS}" = "nvme" ] && loaderdisk="${loaderdisk}p"
[ "${BUS}" = "mmc" ] && loaderdisk="${loaderdisk}p"
[ "${BUS}" = "block" ] && loaderdisk="${loaderdisk}p"
tcrppart="${loaderdisk}3"
# update tinycore 14.0 2023.12.18
update_tinycore
# restore user_config.json file from /mnt/sd#/lastsession directory 2023.10.21
#restoresession
TMP_PATH=/tmp
LOG_FILE="${TMP_PATH}/log.txt"
USER_CONFIG_FILE="/home/tc/user_config.json"
if [ ! -f "${USER_CONFIG_FILE}" ]; then
echo "Not Found User config file, program Exit!!!"
echo "press any key to continue..."
read answer
exit 99
fi
MODEL=$(jq -r -e '.general.model' "$USER_CONFIG_FILE")
BUILD=$(jq -r -e '.general.version' "$USER_CONFIG_FILE")
SN=$(jq -r -e '.extra_cmdline.sn' "$USER_CONFIG_FILE")
MACADDR1=$(jq -r -e '.extra_cmdline.mac1' "$USER_CONFIG_FILE")
MACADDR2="$(jq -r -e '.extra_cmdline.mac2' $USER_CONFIG_FILE)"
MACADDR3="$(jq -r -e '.extra_cmdline.mac3' $USER_CONFIG_FILE)"
MACADDR4="$(jq -r -e '.extra_cmdline.mac4' $USER_CONFIG_FILE)"
NETNUM="1"
LAYOUT=$(jq -r -e '.general.layout' "$USER_CONFIG_FILE")
KEYMAP=$(jq -r -e '.general.keymap' "$USER_CONFIG_FILE")
DMPM=$(jq -r -e '.general.devmod' "$USER_CONFIG_FILE")
LDRMODE=$(jq -r -e '.general.loadermode' "$USER_CONFIG_FILE")
ucode=$(jq -r -e '.general.ucode' "$USER_CONFIG_FILE")
lcode=$(echo $ucode | cut -c 4-)
BLOCK_EUDEV="N"
# for test gettext
#path_i="/usr/local/share/locale/ko_KR/LC_MESSAGES"
#sudo mkdir -p "${path_i}"
#cat "tcrp.po"
#msgfmt "tcrp.po" -o "tcrp.mo"
#sudo cp -vf "tcrp.mo" "${path_i}/tcrp.mo"
###############################################################################
# Mounts backtitle dynamically
function backtitle() {
BACKTITLE="TCRP-mshell ${VERSION}"
BACKTITLE+=" ${DMPM}"
BACKTITLE+=" ${ucode}"
BACKTITLE+=" ${LDRMODE}"
[ -n "${MODEL}" ] && BACKTITLE+=" ${MODEL}" || BACKTITLE+=" (no model)"
[ -n "${BUILD}" ] && BACKTITLE+=" ${BUILD}" || BACKTITLE+=" (no build)"
[ -n "${SN}" ] && BACKTITLE+=" ${SN}" || BACKTITLE+=" (no SN)"
[ -n "${IP}" ] && BACKTITLE+=" ${IP}" || BACKTITLE+=" (no IP)"
[ ! -n "${MACADDR1}" ] && BACKTITLE+=" (no MAC1)" || BACKTITLE+=" ${MACADDR1}"
[ ! -n "${MACADDR2}" ] && BACKTITLE+=" (no MAC2)" || BACKTITLE+=" ${MACADDR2}"
[ ! -n "${MACADDR3}" ] && BACKTITLE+=" (no MAC3)" || BACKTITLE+=" ${MACADDR3}"
[ ! -n "${MACADDR4}" ] && BACKTITLE+=" (no MAC4)" || BACKTITLE+=" ${MACADDR4}"
[ -n "${KEYMAP}" ] && BACKTITLE+=" (${LAYOUT}/${KEYMAP})" || BACKTITLE+=" (qwerty/us)"
echo ${BACKTITLE}
}
###############################################################################
# identify usb's pid vid
function usbidentify() {
checkmachine
if [ "$MACHINE" = "VIRTUAL" ] && [ "$HYPERVISOR" = "VMware" ]; then
echo "Running on VMware, no need to set USB VID and PID, you should SATA shim instead"
elif [ "$MACHINE" = "VIRTUAL" ] && [ "$HYPERVISOR" = "KVM" ]; then
echo "Running on Proxmox/QEMU(KVM), If you are using USB shim, VID 0x46f4 and PID 0x0001 should work for you"
vendorid="0x46f4"
productid="0x0001"
echo "Vendor ID : $vendorid Product ID : $productid"
json="$(jq --arg var "$productid" '.extra_cmdline.pid = $var' user_config.json)" && echo -E "${json}" | jq . >user_config.json
json="$(jq --arg var "$vendorid" '.extra_cmdline.vid = $var' user_config.json)" && echo -E "${json}" | jq . >user_config.json
else
lsusb -v 2>&1 | grep -B 33 -A 1 SCSI >/tmp/lsusb.out
usblist=$(grep -B 33 -A 1 SCSI /tmp/lsusb.out)
vendorid=$(grep -B 33 -A 1 SCSI /tmp/lsusb.out | grep -i idVendor | awk '{print $2}')
productid=$(grep -B 33 -A 1 SCSI /tmp/lsusb.out | grep -i idProduct | awk '{print $2}')
if [ $(echo $vendorid | wc -w) -gt 1 ]; then
echo "Found more than one USB disk devices."
echo "Please leave it to the FRIEND kernel."
echo "Automatically obtains the VID/PID of the required bootloader USB."
rm /tmp/lsusb.out
else
usbdevice="$(grep iManufacturer /tmp/lsusb.out | awk '{print $3}') $(grep iProduct /tmp/lsusb.out | awk '{print $3}') SerialNumber: $(grep iSerial /tmp/lsusb.out | awk '{print $3}')"
if [ -n "$usbdevice" ] && [ -n "$vendorid" ] && [ -n "$productid" ]; then
echo "Found $usbdevice"
echo "Vendor ID : $vendorid Product ID : $productid"
json="$(jq --arg var "$productid" '.extra_cmdline.pid = $var' user_config.json)" && echo -E "${json}" | jq . >user_config.json
json="$(jq --arg var "$vendorid" '.extra_cmdline.vid = $var' user_config.json)" && echo -E "${json}" | jq . >user_config.json
else
echo "Sorry, no usb disk could be identified"
rm /tmp/lsusb.out
fi
fi
fi
}
###############################################################################
# Shows available between DDSML and EUDEV
function seleudev() {
checkforsas
eval "MSG27=\"\${MSG${tz}27}\""
eval "MSG26=\"\${MSG${tz}26}\""
eval "MSG40=\"\${MSG${tz}40}\""
if [ "${MODEL}" = "SA6400" ]||[ "${BUS}" = "mmc" ]; then
while true; do
dialog --clear --backtitle "`backtitle`" \
--menu "Choose a option" 0 0 0 \
e "${MSG26}" \
f "${MSG40}" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "e" ]; then
DMPM="EUDEV"
break
elif [ "${resp}" = "f" ]; then
DMPM="DDSML+EUDEV"
break
fi
done
else
if [ ${BLOCK_EUDEV} = "Y" ]; then
while true; do
dialog --clear --backtitle "`backtitle`" \
--menu "Choose a option" 0 0 0 \
d "${MSG27}" \
f "${MSG40}" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "d" ]; then
DMPM="DDSML"
break
elif [ "${resp}" = "f" ]; then
DMPM="DDSML+EUDEV"
break
fi
done
else
while true; do
dialog --clear --backtitle "`backtitle`" \
--menu "Choose a option" 0 0 0 \
d "${MSG27}" \
e "${MSG26}" \
f "${MSG40}" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "d" ]; then
DMPM="DDSML"
break
elif [ "${resp}" = "e" ]; then
DMPM="EUDEV"
break
elif [ "${resp}" = "f" ]; then
DMPM="DDSML+EUDEV"
break
fi
done
fi
fi
curl -kL# https://raw.githubusercontent.com/PeterSuh-Q3/redpill-load/master/bundled-exts.json -o /home/tc/redpill-load/bundled-exts.json
sudo rm -rf /home/tc/redpill-load/custom/extensions/ddsml
sudo rm -rf /home/tc/redpill-load/custom/extensions/eudev
writeConfigKey "general" "devmod" "${DMPM}"
}
###############################################################################
# Shows available between FRIEND and JOT
function selectldrmode() {
eval "MSG28=\"\${MSG${tz}28}\""
eval "MSG29=\"\${MSG${tz}29}\""
while true; do
dialog --clear --backtitle "`backtitle`" \
--menu "Choose a option" 0 0 0 \
f "${MSG28}" \
j "${MSG29}" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "f" ]; then
LDRMODE="FRIEND"
break
elif [ "${resp}" = "j" ]; then
LDRMODE="JOT"
break
fi
done
writeConfigKey "general" "loadermode" "${LDRMODE}"
}
###############################################################################
# Shows available dsm verwsion
function selectversion () {
while true; do
cmd=(dialog --clear --backtitle "`backtitle`" --menu "Choose an option" 0 0 0)
if [ "${MODEL}" != "DS3615xs" ]; then
options=("a" "7.2.2-72806" "b" "7.2.1-69057" "c" "7.2.0-64570" "d" "7.1.1-42962")
else
options=("d" "7.1.1-42962")
fi
case $MODEL in
DS923+ | DS723+ | DS1823+ | DVA1622 | DS1522+ | DS423+ | RS2423+ )
;;
* )
options+=("e" "7.0.1-42218")
;;
esac
for ((i=0; i<${#options[@]}; i+=2)); do
cmd+=("${options[i]}" "${options[i+1]}")
done
"${cmd[@]}" 2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
case $resp in
"a") BUILD="7.2.2-72806"; break;;
"b") BUILD="7.2.1-69057"; break;;
"c") BUILD="7.2.0-64570"; break;;
"d") BUILD="7.1.1-42962"; break;;
"e") BUILD="7.0.1-42218"; break;;
*) echo "Invalid option";;
esac
done
writeConfigKey "general" "version" "${BUILD}"
}
###############################################################################
# Shows available models to user choose one
function modelMenu() {
M_GRP1="SA6400 DS3622xs+ DS1621xs+ RS3621xs+ RS4021xs+ DS3617xs RS3618xs" #RS1619xs+
M_GRP2="DS3615xs"
M_GRP3="DVA3221 DVA3219 DS1819+ DS2419+"
M_GRP4="DS218+ DS918+ DS1019+ DS620slim DS718+"
M_GRP5="DS923+ DS723+ DS1522+"
M_GRP6="DS1621+ DS1821+ DS1823xs+ DS2422+ FS2500 RS1221+ RS2423+"
M_GRP7="DS220+ DS423+ DS720+ DS920+ DS1520+ DVA1622"
RESTRICT=1
while true; do
echo "" > "${TMP_PATH}/mdl"
# if [ "$HBADETECT" = "ON" ]; then
# if [ "${AFTERHASWELL}" == "OFF" ]; then
# echo "${M_GRP1}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
# echo "${M_GRP2}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
# else
# echo "${M_GRP1}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
# echo "${M_GRP2}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
# echo "${M_GRP4}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
# echo "${M_GRP3}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
# fi
# else
if [ "${AFTERHASWELL}" == "OFF" ]; then
echo "${M_GRP1}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP2}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP5}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP6}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
else
echo "${M_GRP1}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP2}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP4}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP5}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP7}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP6}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP3}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
RESTRICT=0
fi
# fi
if [ ${RESTRICT} -eq 1 ]; then
echo "Release-model-restriction" >> "${TMP_PATH}/mdl"
else
echo "" > "${TMP_PATH}/mdl"
echo "${M_GRP1}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP2}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP4}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP5}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP7}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP6}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
echo "${M_GRP3}" | tr ' ' '\n' >> "${TMP_PATH}/mdl"
fi
echo "" > "${TMP_PATH}/mdl_final"
line_number=2
model_list=$(tail -n +$line_number "${TMP_PATH}/mdl")
while read -r model; do
suggestion=$(setSuggest $model)
echo "$model \"\Zb$suggestion\Zn\"" >> "${TMP_PATH}/mdl_final"
done <<< "$model_list"
dialog --backtitle "`backtitle`" --default-item "${MODEL}" --colors \
--menu "Choose a model\n" 0 0 0 \
--file "${TMP_PATH}/mdl_final" 2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "Release-model-restriction" ]; then
RESTRICT=0
continue
fi
break
done
MODEL="`<${TMP_PATH}/resp`"
writeConfigKey "general" "model" "${MODEL}"
setSuggest $MODEL
if [ "${MODEL}" = "DS3615xs" ]; then
BUILD="7.1.1-42962"
else
#elif [ "${MODEL}" = "DS923+" ] || [ "${MODEL}" = "DS723+" ] || [ "${MODEL}" = "DS1823+" ] || [ "${MODEL}" = "DVA1622" ]; then
BUILD="7.2.2-72806"
fi
writeConfigKey "general" "version" "${BUILD}"
if [ "${MODEL}" = "SA6400" ]||[ "${BUS}" = "mmc" ]; then
if [ "$HBADETECT" = "ON" ]; then
DMPM="DDSML+EUDEV"
else
DMPM="EUDEV"
fi
else
DMPM="DDSML"
fi
writeConfigKey "general" "devmod" "${DMPM}"
}
# Set Describe model-specific requirements or suggested hardware
function setSuggest() {
case $1 in
DS620slim) platform="apollolake";bay="TOWER_6_Bay";mcpu="Intel Celeron J3355";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS1019+) platform="apollolake";bay="TOWER_5_Bay";mcpu="Intel Celeron J3455";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS1520+) platform="geminilake(DT)";bay="TOWER_5_Bay";mcpu="Intel Celeron J4125";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS1522+) platform="r1000(DT)";bay="TOWER_5_Bay";mcpu="AMD Ryzen R1600";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}20}\"";;
DS1621+) platform="v1000(DT)";bay="TOWER_6_Bay";mcpu="AMD Ryzen V1500B";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}22}\"";;
DS1821+) platform="v1000(DT)";bay="TOWER_8_Bay";mcpu="AMD Ryzen V1500B";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}22}\"";;
DS1823xs+) platform="v1000(DT)";bay="TOWER_8_Bay";mcpu="AMD Ryzen V1780B";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}22}\"";;
DS1621xs+) platform="broadwellnk";bay="TOWER_6_Bay";mcpu="Intel Xeon D-1527";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}16}\"";;
DS218+) platform="apollolake";bay="TOWER_2_Bay";mcpu="Intel Celeron J3355";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS220+) platform="geminilake(DT)";bay="TOWER_2_Bay";mcpu="Intel Celeron J4125";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS2422+) platform="v1000(DT)";bay="TOWER_12_Bay";mcpu="AMD Ryzen V1500B";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}22}\"";;
DS3615xs) platform="bromolow";bay="TOWER_12_Bay";mcpu="Intel Core i3-4130";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}22}\"";;
DS3617xs) platform="broadwell";bay="TOWER_12_Bay";mcpu="Intel Xeon D-1527";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}16}\"";;
DS3622xs+) platform="broadwellnk";bay="TOWER_12_Bay";mcpu="Intel Xeon D-1531";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}16}\"";;
DS423+) platform="geminilake(DT)";bay="TOWER_4_Bay";mcpu="Intel Celeron J4125";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS718+) platform="apollolake";bay="TOWER_2_Bay";mcpu="Intel Celeron J3455";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS720+) platform="geminilake(DT)";bay="TOWER_2_Bay";mcpu="Intel Celeron J4125";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS723+) platform="r1000(DT)";bay="TOWER_2_Bay";mcpu="AMD Ryzen R1600";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}20}\"";;
DS918+) platform="apollolake";bay="TOWER_4_Bay";mcpu="Intel Celeron J3455";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS920+) platform="geminilake(DT)";bay="TOWER_4_Bay";mcpu="Intel Celeron J4125";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}\"";;
DS923+) platform="r1000(DT)";bay="TOWER_4_Bay";mcpu="AMD Ryzen R1600";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}20}\"";;
DVA1622) platform="geminilake(DT)";bay="TOWER_2_Bay";mcpu="Intel Celeron J4125";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}17}, \${MSG${tz}21}\"";;
DS1819+) platform="denverton";bay="TOWER_8_Bay";mcpu="Intel Atom C3538";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}23}, \${MSG${tz}25}, \${MSG${tz}21}\"";;
DS2419+) platform="denverton";bay="TOWER_12_Bay";mcpu="Intel Atom C3538";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}23}, \${MSG${tz}25}, \${MSG${tz}21}\"";;
DVA3219) platform="denverton";bay="TOWER_4_Bay";mcpu="Intel Atom C3538";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}23}, \${MSG${tz}25}, \${MSG${tz}21}\"";;
DVA3221) platform="denverton";bay="TOWER_4_Bay";mcpu="Intel Atom C3538";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}23}, \${MSG${tz}24}, \${MSG${tz}21}\"";;
FS2500) platform="v1000(DT)";bay="RACK_12_Bay_2";mcpu="AMD Ryzen V1780B";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}22}\"";;
RS1221+) platform="v1000(DT)";bay="RACK_8_Bay";mcpu="AMD Ryzen V1500B";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}22}\"";;
RS2423+) platform="v1000(DT)";bay="RACK_12_Bay";mcpu="AMD Ryzen V1500B";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}22}\"";;
RS3618xs) platform="broadwell";bay="RACK_12_Bay";mcpu="Intel Xeon D-1521";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}16}\"";;
RS3621xs+) platform="broadwellnk";bay="RACK_12_Bay";mcpu="Intel Xeon D-1541";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}16}\"";;
RS4021xs+) platform="broadwellnk";bay="RACK_16_Bay";mcpu="Intel Xeon D-1541";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}16}\"";;
#RS1619xs+) platform="broadwellnk";bay="RACK_16_Bay";mcpu="Intel Xeon D-1541";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu}, \${MSG${tz}16}\"";;
SA6400) platform="epyc7002(DT)";bay="RACK_12_Bay";mcpu="AMD EPYC 7272";eval "desc=\"[${MODEL}]:${platform},${bay},${mcpu} \"";;
esac
if [ $(echo ${platform} | grep "(DT)" | wc -l) -gt 0 ]; then
eval "MSG00=\"\${MSG${tz}00}\""
else
MSG00="\n"
fi
result="${MSG00}${desc}"
echo "${platform} : ${bay} : ${mcpu}"
}
# Set Storage Panel Size
function storagepanel() {
BAYSIZE="${bay}"
dialog --backtitle "`backtitle`" --default-item "${BAYSIZE}" --no-items \
--menu "Choose a Panel Size" 0 0 0 "TOWER_1_Bay" "TOWER_2_Bay" "TOWER_4_Bay" "TOWER_4_Bay_J" \
"TOWER_4_Bay_S" "TOWER_5_Bay" "TOWER_6_Bay" "TOWER_8_Bay" "TOWER_12_Bay" \
"RACK_2_Bay" "RACK_4_Bay" "RACK_8_Bay" "RACK_10_Bay" \
"RACK_12_Bay" "RACK_12_Bay_2" "RACK_16_Bay" "RACK_20_Bay" "RACK_24_Bay" "RACK_60_Bay" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
BAYSIZE="`<${TMP_PATH}/resp`"
writeConfigKey "general" "bay" "${BAYSIZE}"
bay="${BAYSIZE}"
}
###############################################################################
# Shows menu to user type one or generate randomly
function serialMenu() {
eval "MSG30=\"\${MSG${tz}30}\""
eval "MSG31=\"\${MSG${tz}31}\""
while true; do
dialog --clear --backtitle "`backtitle`" \
--menu "Choose a option" 0 0 0 \
a "${MSG30}" \
m "${MSG31}" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "m" ]; then
while true; do
dialog --backtitle "`backtitle`" \
--inputbox "Please enter a serial number " 0 0 "" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
SERIAL=`cat ${TMP_PATH}/resp`
if [ -z "${SERIAL}" ]; then
return
else
break
fi
done
break
elif [ "${resp}" = "a" ]; then
SERIAL=`./sngen.sh "${MODEL}"-"${BUILD}"`
break
fi
done
SN="${SERIAL}"
writeConfigKey "extra_cmdline" "sn" "${SN}"
}
###############################################################################
# Shows menu to generate randomly or to get realmac
function macMenu() {
eval "MSG32=\"\${MSG${tz}32}\""
eval "MSG33=\"\${MSG${tz}33}\""
eval "MSG34=\"\${MSG${tz}34}\""
while true; do
dialog --clear --backtitle "`backtitle`" \
--menu "Choose a option" 0 0 0 \
c "${MSG32}" \
d "${MSG33}" \
m "${MSG34}" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "d" ]; then
MACADDR=`./macgen.sh "randommac" $1 ${MODEL}`
break
elif [ "${resp}" = "c" ]; then
MACADDR=`./macgen.sh "realmac" $1 ${MODEL}`
break
elif [ "${resp}" = "m" ]; then
while true; do
dialog --backtitle "`backtitle`" \
--inputbox "Please enter a mac address " 0 0 "" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
MACADDR=`cat ${TMP_PATH}/resp`
if [ -z "${MACADDR}" ]; then
return
else
break
fi
done
break
fi
done
if [ "$1" = "eth0" ]; then
MACADDR1="${MACADDR}"
writeConfigKey "extra_cmdline" "mac1" "${MACADDR1}"
fi
if [ "$1" = "eth1" ]; then
MACADDR2="${MACADDR}"
writeConfigKey "extra_cmdline" "mac2" "${MACADDR2}"
writeConfigKey "extra_cmdline" "netif_num" "2"
fi
if [ "$1" = "eth2" ]; then
MACADDR3="${MACADDR}"
writeConfigKey "extra_cmdline" "mac3" "${MACADDR3}"
writeConfigKey "extra_cmdline" "netif_num" "3"
fi
if [ "$1" = "eth3" ]; then
MACADDR4="${MACADDR}"
writeConfigKey "extra_cmdline" "mac4" "${MACADDR4}"
writeConfigKey "extra_cmdline" "netif_num" "4"
fi
}
function prevent() {
prevent_init="ON"
echo "Enable SataPortMap/DiskIdxMap initialization protection"
echo "press any key to continue..."
read answer
}
###############################################################################
# Permits user edit the user config
function editUserConfig() {
while true; do
dialog --backtitle "`backtitle`" --title "Edit with caution" \
--editbox "${USER_CONFIG_FILE}" 0 0 2>"${TMP_PATH}/userconfig"
[ $? -ne 0 ] && return
# JSON format validation
if jq . "${TMP_PATH}/userconfig" > /dev/null 2>&1; then
mv "${TMP_PATH}/userconfig" "${USER_CONFIG_FILE}"
[ $? -eq 0 ] && break
else
dialog --backtitle "`backtitle`" --title "Invalid JSON format" --msgbox "The JSON format is invalid." 0 0
fi
done
MODEL="$(jq -r -e '.general.model' $USER_CONFIG_FILE)"
SN="$(jq -r -e '.extra_cmdline.sn' $USER_CONFIG_FILE)"
MACADDR1="$(jq -r -e '.extra_cmdline.mac1' $USER_CONFIG_FILE)"
MACADDR2="$(jq -r -e '.extra_cmdline.mac2' $USER_CONFIG_FILE)"
MACADDR3="$(jq -r -e '.extra_cmdline.mac3' $USER_CONFIG_FILE)"
MACADDR4="$(jq -r -e '.extra_cmdline.mac4' $USER_CONFIG_FILE)"
NETNUM"=$(jq -r -e '.extra_cmdline.netif_num' $USER_CONFIG_FILE)"
}
###############################################################################
# view linuxrc.syno.log file with textbox
function viewerrorlog() {
if [ -f "/mnt/${loaderdisk}1/logs/jr/linuxrc.syno.log" ]; then
while true; do
dialog --backtitle "`backtitle`" --title "View linuxrc.syno.log file" \
--textbox "/mnt/${loaderdisk}1/logs/jr/linuxrc.syno.log" 0 0
[ $? -eq 0 ] && break
done
else
echo "/mnt/${loaderdisk}1/logs/jr/linuxrc.syno.log file not found!"
echo "press any key to continue..."
read answer
fi
return 0
}
function checkUserConfig() {
if [ ! -n "${SN}" ]; then
#eval "echo \${MSG${tz}36}"
#eval "echo \${MSG${tz}35}"
#read answer
#return 1
SN=`./sngen.sh "${MODEL}"-"${BUILD}"`
writeConfigKey "extra_cmdline" "sn" "${SN}"
fi
if [ ! -n "${MACADDR1}" ]; then
#eval "echo \${MSG${tz}37}"
#eval "echo \${MSG${tz}35}"
#read answer
#return 1
MACADDR1=`./macgen.sh "realmac" "eth0" ${MODEL}`
writeConfigKey "extra_cmdline" "mac1" "${MACADDR1}"
fi
if [ $(ifconfig | grep eth1 | wc -l) -gt 0 ] && [ ! -n "${MACADDR2}" ]; then
MACADDR2=`./macgen.sh "realmac" "eth1" ${MODEL}`
writeConfigKey "extra_cmdline" "mac2" "${MACADDR2}"
fi
if [ $(ifconfig | grep eth2 | wc -l) -gt 0 ] && [ ! -n "${MACADDR3}" ]; then
MACADDR3=`./macgen.sh "realmac" "eth2" ${MODEL}`
writeConfigKey "extra_cmdline" "mac3" "${MACADDR3}"
fi
if [ $(ifconfig | grep eth3 | wc -l) -gt 0 ] && [ ! -n "${MACADDR4}" ]; then
MACADDR4=`./macgen.sh "realmac" "eth3" ${MODEL}`
writeConfigKey "extra_cmdline" "mac4" "${MACADDR4}"
fi
netif_num=$(jq -r -e '.extra_cmdline.netif_num' $USER_CONFIG_FILE)
netif_num_cnt=$(cat $USER_CONFIG_FILE | grep \"mac | wc -l)
if [ $netif_num != $netif_num_cnt ]; then
echo "netif_num = ${netif_num}"
echo "number of mac addresses = ${netif_num_cnt}"
eval "echo \${MSG${tz}38}"
eval "echo \${MSG${tz}35}"
read answer
return 1
fi
if [ "$netif_num" == "2" ]; then
if [ "$MACADDR1" == "$MACADDR2" ]; then
echo "mac1 and mac2 cannot be set identically"
read answer
return 1
fi
elif [ "$netif_num" == "3" ]; then
if [ "$MACADDR1" == "$MACADDR2" ]||[ "$MACADDR1" == "$MACADDR3" ]||[ "$MACADDR2" == "$MACADDR3" ]; then
echo "mac1, mac2 and mac3 cannot have the same value"
read answer
return 1
fi
elif [ "$netif_num" == "4" ]; then
if [ "$MACADDR1" == "$MACADDR2" ]||[ "$MACADDR1" == "$MACADDR3" ]||[ "$MACADDR1" == "$MACADDR4" ]||[ "$MACADDR2" == "$MACADDR3" ]||[ "$MACADDR2" == "$MACADDR4" ]||[ "$MACADDR3" == "$MACADDR4" ]; then
echo "mac1, mac2, mac3 and mac4 cannot have the same value"
read answer
return 1
fi
fi
}
###############################################################################
# Where the magic happens!
function make() {
checkUserConfig
if [ $? -ne 0 ]; then
dialog --backtitle "`backtitle`" --title "Error loader building" 0 0 #--textbox "${LOG_FILE}" 0 0
return 1
fi
#if [ "${BUS}" != "usb" ] && [ ${platform} = "apollolake" ] && [ "$HYPERVISOR" = "KVM" ]; then
# echo "When using SATA/NVMe type loader + Apollolake + proxmox(kvm)/qemu(kvm), loader build is not possible. KP occurs in versions after lkm 24.8.29..."
# echo "press any key to continue..."
# read answer
# return 1
#fi
usbidentify
clear
if [ "${prevent_init}" = "OFF" ]; then
my "${MODEL}"-"${BUILD}" noconfig "${1}" | tee "/home/tc/zlastbuild.log"
else
my "${MODEL}"-"${BUILD}" noconfig "${1}" prevent_init | tee "/home/tc/zlastbuild.log"
fi
if [ -f /home/tc/custom-module/redpill.ko ]; then
echo "Removing redpill.ko ..."
rm -rf /home/tc/custom-module/redpill.ko
fi
if [ $? -ne 0 ]; then
dialog --backtitle "`backtitle`" --title "Error loader building" 0 0 #--textbox "${LOG_FILE}" 0 0
return 1
fi
st "finishloader" "Loader build status" "Finished building the loader"
echo "Ready!"
echo "press any key to continue..."
read answer
rm -f /home/tc/buildstatus
return 0
}
###############################################################################
# Post Update for jot mode
function postupdate() {
my "${MODEL}" postupdate | tee "/home/tc/zpostupdate.log"
echo "press any key to continue..."
read answer
return 0
}
function writexsession() {
echo "Inject urxvt menu.sh into /home/tc/.xsession."
sed -i "/locale/d" .xsession
sed -i "/utf8/d" .xsession
sed -i "/UTF-8/d" .xsession
sed -i "/aterm/d" .xsession
sed -i "/urxvt/d" .xsession
echo "export LANG=${ucode}.UTF-8" >> .xsession
echo "export LC_ALL=${ucode}.UTF-8" >> .xsession
echo "[ ! -d /usr/lib/locale ] && sudo mkdir /usr/lib/locale &" >> .xsession
echo "sudo localedef -c -i ${ucode} -f UTF-8 ${ucode}.UTF-8" >> .xsession
echo "sudo localedef -f UTF-8 -i ${ucode} ${ucode}.UTF-8" >> .xsession
echo "urxvt -geometry 78x32+10+0 -fg orange -title \"TCRP-mshell urxvt Menu\" -e /home/tc/menu.sh &" >> .xsession
sed -i "/rploader/d" .xsession
echo "aterm -geometry 78x32+525+0 -fg yellow -title \"TCRP Monitor\" -e /home/tc/monitor.sh &" >> .xsession
echo "aterm -geometry 78x25+10+430 -title \"TCRP Build Status\" -e /home/tc/ntp.sh &" >> .xsession
echo "aterm -geometry 78x25+525+430 -fg green -title \"TCRP Extra Terminal\" &" >> .xsession
}
###############################################################################
# Shows available language to user choose one
function langMenu() {
dialog --backtitle "`backtitle`" --default-item "${LAYOUT}" --no-items \
--menu "Choose a language" 0 0 0 "English" "한국어" "日本語" "中文" "Русский" \
"Français" "Deutsch" "Español" "Italiano" "brasileiro" \
"Magyar" "bahasa_Indonesia" "Türkçe" "हिंदी" "عربي" \
"አማርኛ" "ไทย" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
case `<"${TMP_PATH}/resp"` in
English) tz="US"; ucode="en_US";;
한국어) tz="KR"; ucode="ko_KR";;
日本語) tz="JP"; ucode="ja_JP";;
中文) tz="CN"; ucode="zh_CN";;
Русский) tz="RU"; ucode="ru_RU";;
Français) tz="FR"; ucode="fr_FR";;
Deutsch) tz="DE"; ucode="de_DE";;
Español) tz="ES"; ucode="es_ES";;
Italiano) tz="IT"; ucode="it_IT";;
brasileiro) tz="BR"; ucode="pt_BR";;
Magyar) tz="HU"; ucode="hu_HU";;
bahasa_Indonesia) tz="ID"; ucode="id_ID";;
Türkçe) tz="TR"; ucode="tr_TR";;
हिंदी) tz="IN"; ucode="hi_IN";;
عربي) tz="EG"; ucode="ar_EG";;
አማርኛ) tz="ET"; ucode="am_ET";;
ไทย) tz="TH"; ucode="th_TH";;
esac
export LANG=${ucode}.UTF-8
export LC_ALL=${ucode}.UTF-8
set -o allexport
[ ! -d /usr/lib/locale ] && sudo mkdir /usr/lib/locale
sudo localedef -c -i ${ucode} -f UTF-8 ${ucode}.UTF-8
sudo localedef -f UTF-8 -i ${ucode} ${ucode}.UTF-8
writeConfigKey "general" "ucode" "${ucode}"
writexsession
tz="US"
load_us
setSuggest $MODEL
return 0
}
###############################################################################
# Shows available keymaps to user choose one
function keymapMenu() {
dialog --backtitle "`backtitle`" --default-item "${LAYOUT}" --no-items \
--menu "Choose a layout" 0 0 0 "azerty" "colemak" \
"dvorak" "fgGIod" "olpc" "qwerty" "qwertz" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
LAYOUT="`<${TMP_PATH}/resp`"
OPTIONS=""
while read KM; do
OPTIONS+="${KM::-5} "
done < <(cd /usr/share/kmap/${LAYOUT}; ls *.kmap)
dialog --backtitle "`backtitle`" --no-items --default-item "${KEYMAP}" \
--menu "Choice a keymap" 0 0 0 ${OPTIONS} \
2>/tmp/resp
[ $? -ne 0 ] && return
resp=`cat /tmp/resp 2>/dev/null`
[ -z "${resp}" ] && return
KEYMAP=${resp}
writeConfigKey "general" "layout" "${LAYOUT}"
writeConfigKey "general" "keymap" "${KEYMAP}"
sed -i "/loadkmap/d" /opt/bootsync.sh
echo "loadkmap < /usr/share/kmap/${LAYOUT}/${KEYMAP}.kmap &" >> /opt/bootsync.sh
echo 'Y'|rploader backup
echo
echo "Since the keymap has been changed,"
restart
}
function erasedisk() {
./edisk.sh
echo "press any key to continue..."
read answer
return 0
}
function backup() {
echo "Cleaning redpill-load/cache directory for backup!"
if [ -d /home/tc/old ]; then
rm -rf /home/tc/old
fi
if [ -f /home/tc/oldpat.tar.gz ]; then
rm -f /home/tc/oldpat.tar.gz
fi
if [ -d /home/tc/redpill-load/cache ]; then
rm -f /home/tc/redpill-load/cache/*
fi
if [ -f /home/tc/custom-module ]; then
rm -f /home/tc/custom-module
fi
echo "y"|rploader backup
echo "press any key to continue..."
read answer
return 0
}
function burnloader() {
tcrpdev=/dev/$(mount | grep -i optional | grep cde | awk -F / '{print $3}' | uniq | cut -c 1-3)
listusb=()
# 2024.07.06 Add NVMe
listusb+=( $(lsblk -o PATH,ROTA,TRAN | grep -E '/dev/(sd|nvme)' | grep -v ${tcrpdev} | grep -E '(1 usb|0 sata|0 nvme)' | awk '{print $1}' ) )
if [ ${#listusb[@]} -eq 0 ]; then
echo "No Available USB,SSD or NVMe, press any key continue..."
read answer
return 0
fi
dialog --backtitle "`backtitle`" --no-items --colors \
--menu "Choose a USB Stick, SSD or NVMe for New Loader\n\Z1(Caution!) In the case of SSD(include NVMe), be sure to check whether it is a cache or data disk.\Zn" 0 0 0 "${listusb[@]}" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
loaderdev="`<${TMP_PATH}/resp`"
#leftshm=$(df --block-size=1 | grep /dev/shm | awk '{print $4}')
#if [ 0${leftshm} -gt 02147483648 ]; then
imgversion="${VERSION}"
#else
# imgversion="v1.0.1.0"
#fi
echo "Downloading TCRP-mshell ${imgversion} img file..."
if [ -f /tmp/tinycore-redpill.${imgversion}.m-shell.img ]; then
echo "TCRP-mshell ${imgversion} img file already exists. Skip download..."
else
curl -kL# https://github.com/PeterSuh-Q3/tinycore-redpill/releases/download/${imgversion}/tinycore-redpill.${imgversion}.m-shell.img.gz -o /tmp/tinycore-redpill.${imgversion}.m-shell.img.gz
gunzip /tmp/tinycore-redpill.${imgversion}.m-shell.img.gz
fi
echo "Please wait a moment. Burning ${imgversion} image is in progress..."
sudo dd if=/tmp/tinycore-redpill.${imgversion}.m-shell.img of=${loaderdev} status=progress bs=4M