forked from Roxy09099/rt18
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·698 lines (663 loc) · 20.1 KB
/
build
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
#!/bin/sh
DATE=$(date +%Y-%m-%d)
routersjson="./router-1806.json"
templatefolder="template/"
customfolder="custom/"
buldimage() {
image=$1
flag=$2
cconfig=$3
image_up=$(echo "$image" | tr [a-z] [A-Z])
LIST=$(jshon -k < $routersjson)
echo "$LIST" > modellist.txt
found=0
while read model
do
model_up=$( echo "$model" | tr [a-z] [A-Z])
if [ "$image_up" = "$model_up" ]; then
found=1
model_list=$(jshon -e "$model_up" -k < $routersjson)
fnd=$(echo "$model_list" | grep "type")
if [ ! -z "$fnd" ]; then
model_type=$(jshon -e "$model_up" -e type < $routersjson)
temp="${model_type%\"}"
model_type="${temp#\"}"
case $model_type in
"1" )
temp1=$(jshon -e "$model_up" -e image < $routersjson)
temp="${temp1%\"}"
model_image="${temp#\"}"
temp1=$(jshon -e "$model_up" -e ext < $routersjson)
temp="${temp1%\"}"
model_ext="${temp#\"}"
;;
"2" )
temp1=$(jshon -e "$model_up" -e image1 < $routersjson)
temp="${temp1%\"}"
model_image1="${temp#\"}"
temp1=$(jshon -e "$model_up" -e image2 < $routersjson)
temp="${temp1%\"}"
model_image2="${temp#\"}"
temp1=$(jshon -e "$model_up" -e ext1 < $routersjson)
temp="${temp1%\"}"
model_ext1="${temp#\"}"
temp1=$(jshon -e "$model_up" -e ext2 < $routersjson)
temp="${temp1%\"}"
model_ext2="${temp#\"}"
;;
"3" )
temp1=$(jshon -e "$model_up" -e image1 < $routersjson)
temp="${temp1%\"}"
model_image1="${temp#\"}"
temp1=$(jshon -e "$model_up" -e image2 < $routersjson)
temp="${temp1%\"}"
model_image2="${temp#\"}"
temp1=$(jshon -e "$model_up" -e image3 < $routersjson)
temp="${temp1%\"}"
model_image3="${temp#\"}"
temp1=$(jshon -e "$model_up" -e image4 < $routersjson)
temp="${temp1%\"}"
model_image4="${temp#\"}"
temp1=$(jshon -e "$model_up" -e ext1 < $routersjson)
temp="${temp1%\"}"
model_ext1="${temp#\"}"
temp1=$(jshon -e "$model_up" -e ext2 < $routersjson)
temp="${temp1%\"}"
model_ext2="${temp#\"}"
;;
"4" )
temp1=$(jshon -e "$model_up" -e image1 < $routersjson)
temp="${temp1%\"}"
model_image1="${temp#\"}"
temp1=$(jshon -e "$model_up" -e image2 < $routersjson)
temp="${temp1%\"}"
model_image2="${temp#\"}"
;;
esac
temp1=$(jshon -e "$model_up" -e config < $routersjson)
temp="${temp1%\"}"
model_config="${temp#\"}"
temp1=$(jshon -e "$model_up" -e imagepath < $routersjson)
temp="${temp1%\"}"
model_imagepath="${temp#\"}"
model_imagepath=$(echo $model_imagepath | sed 's!\\!!g')
temp1=$(jshon -e "$model_up" -e mod < $routersjson)
temp="${temp1%\"}"
model_mod="${temp#\"}"
model_addons=""
fnd=$(echo "$model_list" | grep "addons")
if [ ! -z "$fnd" ]; then
cntr=0
item_len=$(jshon -e "$model_up" -e addons -l < $routersjson)
if [ $item_len -gt 0 ]; then
while [ $cntr -lt $item_len ]; do
temp1=$(jshon -e "$model_up" -e addons -e $cntr < $routersjson)
temp="${temp1%\"}"
temp1="${temp#\"}"
temp1=$(echo $temp1 | sed 's!\\!!g')
if [ $cntr -eq 0 ]; then
model_addons=$temp1
else
model_addons=$model_addons"|"$temp1
fi
cntr=$((cntr+1))
done
fi
fi
zippassword=""
fnd=$(echo "$model_list" | grep "zippassword")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e zippassword < $routersjson)
temp="${temp1%\"}"
temp1="${temp#\"}"
zippassword="-P "$(echo $temp1 | sed 's!\\!!g')" "
fi
model_name=""
model_flash="16"
model_hostname=""
model_ssid2g=""
model_ssid5g=""
model_password=""
model_material=""
model_argon=""
model_tomato=""
fnd=$(echo "$model_list" | grep "flash")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e flash < $routersjson)
temp="${temp1%\"}"
temp1="${temp#\"}"
model_flash=$(echo $temp1 | sed 's!\\!!g')
fi
fnd=$(echo "$model_list" | grep "custom")
if [ ! -z "$fnd" ]; then
cust_list=$(jshon -e "$model_up" -e custom -k < $routersjson)
fnd=$(echo "$cust_list" | grep "name")
if [ ! -z "$fnd" ]; then
x_list=$(jshon -e "$model_up" -e custom -e name -k < $routersjson)
fnd=$(echo "$x_list" | grep "model")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e name -e model < $routersjson)
temp="${temp1%\"}"
model_name="${temp#\"}"
fi
fnd=$(echo "$x_list" | grep "hostname")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e name -e hostname < $routersjson)
temp="${temp1%\"}"
model_hostname="${temp#\"}"
fi
fi
fnd=$(echo "$cust_list" | grep "wifi")
if [ ! -z "$fnd" ]; then
x_list=$(jshon -e "$model_up" -e custom -e wifi -k < $routersjson)
fnd=$(echo "$x_list" | grep "SSID2G")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e wifi -e SSID2G < $routersjson)
temp="${temp1%\"}"
model_ssid2g="${temp#\"}"
fi
fnd=$(echo "$x_list" | grep "SSID5G")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e wifi -e SSID5G < $routersjson)
temp="${temp1%\"}"
model_ssid5g="${temp#\"}"
fi
fnd=$(echo "$x_list" | grep "Password")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e wifi -e Password < $routersjson)
temp="${temp1%\"}"
model_password="${temp#\"}"
fi
fi
fnd=$(echo "$cust_list" | grep "image")
if [ ! -z "$fnd" ]; then
x_list=$(jshon -e "$model_up" -e custom -e image -k < $routersjson)
fnd=$(echo "$x_list" | grep "Material")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e image -e Material < $routersjson)
temp="${temp1%\"}"
model_material="${temp#\"}"
fi
fnd=$(echo "$x_list" | grep "Argon")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e image -e Argon < $routersjson)
temp="${temp1%\"}"
model_argon="${temp#\"}"
fi
fnd=$(echo "$x_list" | grep "Tomato")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e image -e Tomato < $routersjson)
temp="${temp1%\"}"
model_tomato="${temp#\"}"
fi
fi
file_list=""
fnd=$(echo "$cust_list" | grep "files")
if [ ! -z "$fnd" ]; then
temp1=$(jshon -e "$model_up" -e custom -e files < $routersjson)
temp="${temp1%\"}"
temp1="${temp#\"}"
file_list="./configfiles"$(echo $temp1 | sed 's!\\!!g')
fi
fi
fi
break
fi
done < ./modellist.txt
if [ $found -eq 0 ];then
if [ ! -z $image ]; then
echo "Model $image is not supported"
echo " "
fi
echo "Usage : <router name> [flag config name]"
echo " "
echo "<router name> is one of the names in the following list"
echo "[flag config name] are optional for working with custom config file for this router"
echo "[flag] : -e create or edit a custom config file"
echo " -eb create or edit a custom config file and then build the image"
echo " -b build an image using the custom config file"
echo "[config name] : name given to a custom config file for this router"
echo " if this config file does not exist then the template"
echo " config file will be used to create it"
echo " "
echo "Supported Models are :"
echo " "
ln=0
while read L1
do
if [ $ln -gt 2 ]; then
ln=0
printf "%-17s\n" $L1
else
ln=$((ln+1))
printf "%-17s" $L1
fi
done < modellist.txt
printf "\n"
rm -f ./modellist.txt
exit 0
fi
rm -f ./modellist.txt
configfix() {
DNS=$(cat "./.config" | grep "CONFIG_PACKAGE_dnsmasq-full=y")
if [ ! -z $DNS ]; then
sed -i -e 's/CONFIG_PACKAGE_dnsmasq=y/# CONFIG_PACKAGE_dnsmasq is not set/g' ./.config
fi
WPAD=$(cat "./.config" | grep "CONFIG_PACKAGE_wpad-basic=y")
if [ ! -z $WPAD ]; then
sed -i -e 's/CONFIG_PACKAGE_wpad-basic=y/# CONFIG_PACKAGE_wpad-basic is not set/g' ./.config
fi
WPAD=$(cat "./.config" | grep "CONFIG_PACKAGE_wpad=y")
if [ ! -z $WPAD ]; then
sed -i -e 's/CONFIG_PACKAGE_wpad-mini=y/# CONFIG_PACKAGE_wpad-mini is not set/g' ./.config
fi
WGET=$(cat "./.config" | grep "CONFIG_PACKAGE_wget ")
if [ ! -z "$WGET" ]; then
WGET=$(cat "./.config" | grep "# CONFIG_PACKAGE_wget is not set")
if [ ! -z "$WGET" ]; then
sed -i -e 's/# CONFIG_PACKAGE_wget is not set/CONFIG_PACKAGE_wget=y/g' ./.config
make defconfig
fi
fi
}
NAME="GoldenOrb_"
CODE=$NAME$DATE
rm -rf ./bin
rm -rf ./files
mkdir -p ./files/etc
echo 'CODENAME="'"$CODE"'"' > ./files/etc/codename
testim="$model_material""$model_argon""$model_tomato"
if [ ! -z "$testim" ]; then
echo " <model>" > ./files/etc/header_msg
if [ ! -z $model_material ]; then
echo "/img/"$model_material >> ./files/etc/header_msg
else
echo "/img/header.png" >> ./files/etc/header_msg
fi
if [ ! -z $model_argon ]; then
echo "/img/"$model_argon >> ./files/etc/header_msg
else
echo "/img/rosy.png" >> ./files/etc/header_msg
fi
if [ ! -z $model_tomato ]; then
echo "/img/"$model_tomato >> ./files/etc/header_msg
else
echo "/img/tomato.png" >> ./files/etc/header_msg
fi
fi
if [ ! -z "$model_name" ]; then
if [ ! -z "$model_name" ]; then
echo "$model_name" > ./files/etc/custom
echo "$model_name" >> ./files/etc/custom
fi
if [ ! -z "$model_hostname" ]; then
echo "$model_hostname" >> ./files/etc/custom
else
echo "ROOter" >> ./files/etc/custom
fi
fi
testim="$model_ssid2g""$model_ssid5g""$model_password"
if [ ! -z "$testim" ]; then
if [ ! -z "$model_ssid2g" ]; then
echo "$model_ssid2g" >> ./files/etc/customwifi
else
echo "ROOter 2G" >> ./files/etc/customwifi
fi
if [ ! -z "$model_ssid5g" ]; then
echo "$model_ssid5g" >> ./files/etc/customwifi
else
echo "ROOter 5G" >> ./files/etc/customwifi
fi
if [ ! -z "$model_password" ]; then
echo "$model_password" >> ./files/etc/customwifi
else
echo "rooter2017" >> ./files/etc/customwifi
fi
fi
addon_list=""
copy_addons() {
if [ ! -z "$model_addons" ]; then
addon_list=$(echo "$model_addons" | sed -r 's![|]+!,!g')","
bd=1
L1=$(echo "$addon_list" | cut -d, -f$bd)
while [ ! -z "$L1" ]
do
cp "./configfiles/addons/"$L1 ./images/$L1
bd=$((bd+1))
L1=$(echo "$addon_list" | cut -d, -f$bd)
done
addon_list=$(echo "$model_addons" | sed -r 's![|]+! !g')
fi
}
del_addons() {
if [ ! -z "$model_addons" ]; then
addon_list=$(echo "$model_addons" | sed -r 's![|]+!,!g')","
bd=1
L1=$(echo "$addon_list" | cut -d, -f$bd)
while [ ! -z "$L1" ]
do
rm -f $L1
bd=$((bd+1))
L1=$(echo "$addon_list" | cut -d, -f$bd)
done
addon_list=$(echo "$model_addons" | sed -r 's![|]+! !g')
fi
}
m_config=$templatefolder$model_config
if [ ! -z $cconfig ]; then
if [ $flag = "-e" ]; then
m_config=$customfolder".config_"$cconfig
if [ ! -e ./configfiles/$m_config ]; then
cp ./configfiles/$templatefolder$model_config ./configfiles/$m_config
fi
cp ./configfiles/$m_config ./.config
# edit and exit
make menuconfig
if [ -e ./.config ]; then
cp ./.config ./configfiles/$m_config
fi
exit 0
else
if [ $flag = "-eb" ]; then
m_config=$customfolder".config_"$cconfig
if [ ! -e ./configfiles/$m_config ]; then
cp ./configfiles/$templatefolder$model_config ./configfiles/$m_config
fi
cp ./configfiles/$m_config ./.config
# edit
make menuconfig
if [ -e ./.config ]; then
cp ./.config ./configfiles/$m_config
else
exit 0
fi
else
if [ $flag = "-b" ]; then
m_config=$customfolder".config_"$cconfig
if [ ! -e ./configfiles/$m_config ]; then
cp ./configfiles/$templatefolder$model_config ./configfiles/$m_config
fi
else
echo "Mangled Parameters"
exit 0
fi
fi
fi
fi
TYP="-GO"
END=$TYP$DATE
if [ ! -z "$file_list" ]; then
cp -r $file_list* ./files
fi
case $model_type in
"1" )
cp ./configfiles/$m_config ./.config
if [ $m_config = $templatefolder$model_config ]; then
if [ $model_flash = "8" ]; then
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter8-vpn is not set/CONFIG_PACKAGE_ext-rooter8-vpn=y/g' ./.config
else
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter-lite is not set/CONFIG_PACKAGE_ext-rooter-lite=y/g' ./.config
fi
fi
make defconfig
configfix
make V=s
cp ./bin/targets$model_imagepath$model_image ./images/$model_mod$END$model_ext
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
copy_addons
cd ./images
zip $zippassword $model_mod$END.zip $model_mod$END$model_ext $addon_list
rm -f $model_mod$END$model_ext
del_addons
cd ..
if [ $model_flash != "8" ]; then
if [ $m_config = $templatefolder$model_config ]; then
cp ./configfiles/$m_config ./.config
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter16 is not set/CONFIG_PACKAGE_ext-rooter16=y/g' ./.config
make defconfig
configfix
make V=s
cp ./bin/targets$model_imagepath$model_image ./images/$model_mod"-full"$END$model_ext
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
cd ./images
zip $zippassword $model_mod$END.zip $model_mod"-full"$END$model_ext
rm -f $model_mod"-full"$END$model_ext
cd ..
fi
fi
;;
"2" )
cp ./configfiles/$m_config ./.config
if [ $m_config = $templatefolder$model_config ]; then
if [ $model_flash = "8" ]; then
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter8-vpn is not set/CONFIG_PACKAGE_ext-rooter8-vpn=y/g' ./.config
else
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter-lite is not set/CONFIG_PACKAGE_ext-rooter-lite=y/g' ./.config
fi
fi
make defconfig
configfix
make V=s
cp ./bin/targets$model_imagepath$model_image1 ./images/$model_mod$END$model_ext1
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
cp ./bin/targets$model_imagepath$model_image2 ./images/$model_mod$END$model_ext2
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
copy_addons
cd ./images
zip $zippassword$model_mod$END.zip $model_mod$END$model_ext1 $model_mod$END$model_ext2 $addon_list
rm -f $model_mod$END$model_ext1
rm -f $model_mod$END$model_ext2
del_addons
cd ..
if [ $model_flash != "8" ]; then
if [ $m_config = $templatefolder$model_config ]; then
cp ./configfiles/$m_config ./.config
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter16 is not set/CONFIG_PACKAGE_ext-rooter16=y/g' ./.config
make defconfig
configfix
make V=s
cp ./bin/targets$model_imagepath$model_image1 ./images/$model_mod"-full"$END$model_ext1
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
cp ./bin/targets$model_imagepath$model_image2 ./images/$model_mod"-full"$END$model_ext2
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
cd ./images
zip $zippassword$model_mod$END.zip $model_mod"-full"$END$model_ext1 $model_mod"-full"$END$model_ext2
rm -f $model_mod"-full"$END$model_ext1
rm -f $model_mod"-full"$END$model_ext2
cd ..
fi
fi
;;
"3" )
cp ./configfiles/$m_config ./.config
if [ $m_config = $templatefolder$model_config ]; then
if [ $model_flash = "8" ]; then
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter8-vpn is not set/CONFIG_PACKAGE_ext-rooter8-vpn=y/g' ./.config
else
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter-lite is not set/CONFIG_PACKAGE_ext-rooter-lite=y/g' ./.config
fi
fi
make defconfig
configfix
make V=s
cp ./bin/targets$model_imagepath$model_image1 ./images/$model_image1
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
cp ./bin/targets$model_imagepath$model_image3 ./images/$model_image3
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
copy_addons
cd ./images
gunzip $model_image1
mv $model_image2 $model_mod$END$model_ext1
gunzip $model_image3
mv $model_image4 $model_mod$END$model_ext2
zip -r $zippassword $model_mod$END.zip $model_mod$END$model_ext1 $model_mod$END$model_ext2 $addon_list
rm -f $model_mod$END$model_ext1
rm -f $model_mod$END$model_ext2
del_addons
cd ..
if [ $model_flash != "8" ]; then
if [ $m_config = $templatefolder$model_config ]; then
cp ./configfiles/$m_config ./.config
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter16 is not set/CONFIG_PACKAGE_ext-rooter16=y/g' ./.config
make defconfig
configfix
make V=s
cp ./bin/targets$model_imagepath$model_image1 ./images/$model_image1
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
cp ./bin/targets$model_imagepath$model_image3 ./images/$model_image3
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
cd ./images
gunzip $model_image1
mv $model_image2 $model_mod"-full"$END$model_ext1
gunzip $model_image3
mv $model_image4 $model_mod"-full"$END$model_ext2
zip -r $zippassword $model_mod$END.zip $model_mod"-full"$END$model_ext1 $model_mod"-full"$END$model_ext2
rm -f $model_mod"-full"$END$model_ext1
rm -f $model_mod"-full"$END$model_ext2
cd ..
fi
fi
;;
"4" )
cp ./configfiles/$m_config ./.config
if [ $m_config = $templatefolder$model_config ]; then
if [ $model_flash = "8" ]; then
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter8-vpn is not set/CONFIG_PACKAGE_ext-rooter8-vpn=y/g' ./.config
else
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter-lite is not set/CONFIG_PACKAGE_ext-rooter-lite=y/g' ./.config
fi
fi
make defconfig
configfix
make V=s
cp ./bin/targets$model_imagepath$model_image1 ./images/$model_image1
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
copy_addons
cd ./images
gunzip $model_image1
mv $model_image2 $model_mod$END"-ext4.img"
zip -r $zippassword $model_mod$END.zip $model_mod$END"-ext4.img" $addon_list
rm -f $model_mod$END"-ext4.img"
rm -f $model_imagepath$model_image1
del_addons
cd ..
if [ $model_flash != "8" ]; then
if [ $m_config = $templatefolder$model_config ]; then
cp ./configfiles/$m_config ./.config
sed -i -e 's/# CONFIG_PACKAGE_ext-rooter16 is not set/CONFIG_PACKAGE_ext-rooter16=y/g' ./.config
make defconfig
configfix
make V=s
cp ./bin/targets$model_imagepath$model_image1 ./images/$model_image1
EX=$?
if [ $EX -ne 0 ]; then
echo "$EX $model_imagepath$model_image"
exit $EX
fi
cd ./images
gunzip $model_image1
mv $model_image2 $model_mod"-full"$END"-ext4.img"
zip -r $zippassword $model_mod$END.zip $model_mod"-full"$END"-ext4.img"
rm -f $model_mod"-full"$END"-ext4.img"
rm -f $model_imagepath$model_image1
cd ..
fi
fi
;;
esac
}
cmd=$1
if [ -z $cmd ]; then
buldimage $1 $2 $3
else
if [ $cmd = "ALL" ]; then
start=$2
flg=0
LIST=$(jshon -k < $routersjson)
echo "$LIST" > alllist.txt
while read L1
do
if [ -z $start ]; then
buldimage "$L1"
else
if [ $flg -eq 0 ]; then
if [ $start = $L1 ]; then
flg=1
buldimage "$L1"
fi
else
buldimage "$L1"
fi
fi
done < alllist.txt
rm -f ./alllist.txt
else
if [ $cmd = "LIST" ]; then
LIST=$(jshon -k < $routersjson)
echo "$LIST"
echo "$LIST" > alllist.txt
else
if [ $cmd = "DETAILS" ]; then
LIST=$(jshon -k < $routersjson)
echo "$LIST" > alllist.txt
while read L1
do
temp1=$(jshon -e "$L1" -e details < $routersjson)
temp="${temp1%\"}"
details="${temp#\"}"
temp1=$(jshon -e "$L1" -e mod < $routersjson)
temp="${temp1%\"}"
mod="${temp#\"}"$END".zip"
echo $mod
echo "$details"
done < alllist.txt
else
buldimage $1 $2 $3
fi
fi
fi
fi