-
Notifications
You must be signed in to change notification settings - Fork 0
/
soft.sh
executable file
·1773 lines (1483 loc) · 46.5 KB
/
soft.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
#!/bin/sh
NO_COLOR=$(tput sgr0)
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
LIME_YELLOW=$(tput setaf 190)
YELLOW=$(tput setaf 3)
POWDER_BLUE=$(tput setaf 153)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
BRIGHT=$(tput bold)
NORMAL=$(tput sgr0)
BLINK=$(tput blink)
REVERSE=$(tput smso)
UNDERLINE=$(tput smul)
Kernel=`uname -r`
# CentOS 5.8
if [[ "$Kernel" == "2.6.18-308.el5" ]]; then
RMX1000_RPM_FILE=${OFFICIAL_DIR}"/SoftMcuRPMs/RPMs/Plcm-Rmx1000-*.el5.x86_64.rpm"
# CentOs 6.3
elif [[ "$Kernel" == "2.6.32-279.el6.x86_64" ]]; then
RMX1000_RPM_FILE=${OFFICIAL_DIR}"/SoftMcuRPMs/RPMs/Plcm-Rmx1000-*.el6.x86_64.rpm"
fi
LAST_BUILD="/Carmel-Versions/CustomerBuild/RMX_100.0/200_last"
DIR_LIST=(MCMS_DIR CS_DIR MPMX_DIR MRMX_DIR ENGINE_DIR)
BUILD_LIST=(MCMS CS MPMX MC AUDIO VIDEO ENGINE)
START_UP_LOG=/tmp/startup_logs/soft_mcu_start_up.log
SERVICE_OUTPUT_LOG=/tmp/startup_logs/soft_mcu_service_output
> $SERVICE_OUTPUT_LOG
#LOG="awk '{ print strftime("%Y%m%d%H%M%S"), $0; }' | tee -a $START_UP_LOG"
LOG="tee -a $START_UP_LOG"
export LD_LIBRARY_PATH=/mcms/Bin
export NATIVE_TOOLCHAIN=YES
export BUILD_MCMS=TRUE
export BUILD_CS=TRUE
export BUILD_MPMX=TRUE
export BUILD_MC=TRUE
export BUILD_AUDIO=TRUE
export BUILD_VIDEO=TRUE
export BUILD_ENGINE=TRUE
export Kernel=`uname -r`
################################ HELP ##################################
if [ "$1" == "" ]
then
echo "usage: soft.sh COMMAND"
echo "commands:"
echo "make [MCMS|CS|MPMX|MC|AUDIO|VIDEO|ENGINE]- build all soft mcu components (native toolchain mode)"
echo "make_clean - clean all soft mcu components"
echo "clean - clean all soft mcu components"
echo "start - start all soft mcu processes"
echo "start [process] - start all soft mcu processes and test specific process with Valgrind, process={mcms process, mfa, mrmx process} - example: soft.sh start mfa"
echo "target - start all soft mcu processes, on an rpm installed target"
echo "stop - stop all soft mcu processes"
echo
echo "mandatory environment variables:"
echo "MCMS_DIR - MCMS main folder"
echo "CS_DIR - CS main folder"
echo "MPMX_DIR - MPMX main folder"
echo "MRMX_DIR - MRMX main folder (MC, AUDIO, VIDEO sources)"
echo "ENGINE_DIR - Engine MRM main folder"
echo
echo "mandatory Soft MCU testing environment variables:"
echo "CALLGEN_IP - Call Generator IP"
echo "EP1 - First End Point IP"
echo "EP2 - Second End Point IP"
echo "optional environment variables:"
echo "FARM=YES - for fast compilation over farm"
exit
fi
#################################################################################
# #
# SERVICE FUNCTIONS #
# #
#################################################################################
###########################################################################
setup_env (){
mkdir -p /tmp/mfa_x86_env/bin /tmp/mfa_x86_env/cfg /tmp/mfa_x86_env/logs
mkdir -p /tmp/mfa_x86_env/mcms_share/cfg /tmp/mfa_x86_env/mcms_share/bin
# CentOs 6.3
if [[ "$Kernel" == "2.6.32-279.el6.x86_64" ]]; then
if [ -e Bin.i32cent63 ]; then
echo "Copy SOFT MCU binaries CentOS 6.3 into Bin folder..."
rm -Rf Bin/*
(
cd Bin
find ../Bin.i32cent63 -type f -exec ln -sf {} . \;
find ../Bin.i32cent63 -type l -exec ln -sf {} . \;
#ln -sf ../Bin.i32ptx/lib* ../Bin.i32ptx/httpd ../Bin.i32ptx/mod_polycom.so ../Bin.i32ptx/libMcmsCs.so \
#../Bin.i32ptx/snmpd ../Bin.i32ptx/openssl ../Bin.i32ptx/ApacheModule ../Bin.i32ptx/McuCmd .
#ln -sf ../Bin.i32cent63/* .
#ln -sf /usr/local/apache2/bin/httpd .
) 2> /dev/null
fi
else
if [ -e Bin.i32cent56 ]; then
echo "Copy SOFT MCU binaries CentOS 5.6 into Bin folder..."
rm -Rf Bin/*
(
cd Bin
find ../Bin.i32cent56 -type f -exec ln -sf {} . \;
find ../Bin.i32cent56 -type l -exec ln -sf {} . \;
#ln -sf ../Bin.i32ptx/lib* ../Bin.i32ptx/httpd ../Bin.i32ptx/mod_polycom.so ../Bin.i32ptx/libMcmsCs.so \
#../Bin.i32ptx/snmpd ../Bin.i32ptx/openssl ../Bin.i32ptx/ApacheModule ../Bin.i32ptx/McuCmd .
#ln -sf ../Bin.i32cent56/* .
) 2> /dev/null
fi
fi
#Fix INFRA-38
#rm -f Bin/ApacheModule
if [[ $MCMS_DIR == "$OFFICIAL_DIR/mcms/" ]];then
if [[ $CLEAN_CFG != "NO" ]];then
rm -rf $HOME/dev_env/*
fi
setup_env_official_mcms
fi
rm /tmp/mcms
ln -sf $MCMS_DIR /tmp/mcms
if [[ $CS_DIR == "$OFFICIAL_DIR/cs_smcu/CS/" ]];then
setup_env_official_cs
fi
if [[ $MPMX_DIR != "$OFFICIAL_DIR/MediaCard/MFA/MFA/MPMX/" ]]; then
cd $MPMX_DIR
./Script/build-x86_env.sh
cd -
fi
}
###########################################################################
setup_env_official_mcms (){
echo -n "Settup your mcms cfg env..."
USER_MCMS_DIR="$HOME/dev_env/mcms/"
mkdir -p $USER_MCMS_DIR
cd $USER_MCMS_DIR &> /dev/null
mkdir -p Audit Backup CdrFiles Cores Faults IVRX Keys KeysForCS LogFiles MediaRecording Restore States TestResults Bin EMACfg
cd - &> /dev/null
ln -sf $MCMS_DIR/EMA $USER_MCMS_DIR/EMA
ln -sf $MCMS_DIR/Libs $USER_MCMS_DIR/Libs
ln -sf $MCMS_DIR/MIBS $USER_MCMS_DIR/MIBS
ln -sf $MCMS_DIR/Scripts $USER_MCMS_DIR/Scripts
ln -sf $MCMS_DIR/StaticCfg $USER_MCMS_DIR/StaticCfg
ln -sf $MCMS_DIR/VersionCfg $USER_MCMS_DIR/VersionCfg
ln -sf $MCMS_DIR/Makefile $USER_MCMS_DIR/Makefile
ln -sf $MCMS_DIR/Main.mk $USER_MCMS_DIR/Main.mk
ln -sf $MCMS_DIR/Processes $USER_MCMS_DIR/Processes
if [ ! -d $USER_MCMS_DIR/Cfg ]; then
cp -rf $MCMS_DIR/Cfg $USER_MCMS_DIR
fi
if [ ! -d $USER_MCMS_DIR/IVRX ]; then
cp -rf $MCMS_DIR/IVRX $USER_MCMS_DIR
fi
if [ ! -d $USER_MCMS_DIR/Utils ]; then
cp -rf $MCMS_DIR/Utils $USER_MCMS_DIR
fi
# Fix SA on OFFICIAL BUILD
cp -rf ${MCMS_DIR}/StaticCfg $USER_MCMS_DIR
chmod u+w $USER_MCMS_DIR/StaticCfg/httpd.conf.sim
if [[ ! `tail -1 $USER_MCMS_DIR/StaticCfg/httpd.conf.sim | grep '^User'` ]]; then
echo "User `whoami`" >> $USER_MCMS_DIR/StaticCfg/httpd.conf.sim
fi
rm -f $USER_MCMS_DIR/StaticCfg/httpd.conf
cd $USER_MCMS_DIR/StaticCfg
ln -s httpd.conf.sim httpd.conf
cd -
echo "Copy SOFT MCU binaries into Bin folder..."
# CentOs 6.3
if [[ "$Kernel" == "2.6.32-279.el6.x86_64" ]]; then
rm -Rf $USER_MCMS_DIR/Bin/*
(
cd $USER_MCMS_DIR/Bin
#ln -sf $MCMS_DIR/Bin.i32ptx/lib* $MCMS_DIR/Bin.i32ptx/httpd $MCMS_DIR/Bin.i32ptx/mod_polycom.so $MCMS_DIR/Bin.i32ptx/libMcmsCs.so \
ln -sf $MCMS_DIR/Bin.i32ptx/lib* $MCMS_DIR/Bin.i32ptx/mod_polycom.so $MCMS_DIR/Bin.i32ptx/libMcmsCs.so \
$MCMS_DIR/Bin.i32ptx/snmpd $MCMS_DIR/Bin.i32ptx/openssl $MCMS_DIR/Bin.i32ptx/ApacheModule $MCMS_DIR/Bin.i32ptx/McuCmd .
ln -sf $MCMS_DIR/Bin.i32cent63/* .
ln -sf /usr/local/apache/bin/httpd .
) 2> /dev/null
else
rm -Rf $USER_MCMS_DIR/Bin/*
(
cd $USER_MCMS_DIR/Bin
ln -sf $MCMS_DIR/Bin.i32ptx/lib* $MCMS_DIR/Bin.i32ptx/httpd $MCMS_DIR/Bin.i32ptx/mod_polycom.so $MCMS_DIR/Bin.i32ptx/libMcmsCs.so \
$MCMS_DIR/Bin.i32ptx/openssl $MCMS_DIR/Bin.i32ptx/ApacheModule $MCMS_DIR/Bin.i32ptx/McuCmd .
ln -sf $MCMS_DIR/Bin.i32cent56/* .
) 2> /dev/null
fi
export MCMS_DIR=$USER_MCMS_DIR
rm /tmp/mcms
echo "Done."
}
###########################################################################
setup_env_official_cs (){
echo -n "Settup your cs env..."
USER_CS_DIR="$HOME/dev_env/cs/"
mkdir -p $USER_CS_DIR
cd $USER_CS_DIR &> /dev/null
mkdir -p logs/cs1 ocs/cs1
cd - &> /dev/null
rm -f $USER_CS_DIR/bin $USER_CS_DIR/scripts $USER_CS_DIR/lib
ln -sf $CS_DIR/bin $USER_CS_DIR/bin
ln -sf $CS_DIR/scripts $USER_CS_DIR/scripts
ln -sf $CS_DIR/lib $USER_CS_DIR/lib
if [ ! -d $USER_CS_DIR/cfg ]; then
cp -rf $CS_DIR/cfg $USER_CS_DIR
fi
export CS_DIR=$USER_CS_DIR
rm /tmp/cs
ln -sf $CS_DIR /tmp/cs
echo "Done."
}
###########################################################################
export_official () {
case $1 in
MCMS_DIR)
export $1=$OFFICIAL_DIR/mcms/
;;
CS_DIR)
export $1=$OFFICIAL_DIR/cs_smcu/CS/
;;
MPMX_DIR)
export $1=$OFFICIAL_DIR/MediaCard/MFA/MFA/MPMX/
;;
MRMX_DIR)
export $1=$OFFICIAL_DIR/MRMX/
;;
ENGINE_DIR)
export $1=$OFFICIAL_DIR/EngineMRM/
;;
esac
}
##############################################################################
test_using_official (){
OFFICIAL=`echo $1 | grep $OFFICIAL_DIR`
if [[ $OFFICIAL != "" || $1 == "$USER_MCMS_DIR" ]]; then
echo " - Using Official Build $OFFICIAL_DIR"
else
echo " - On a private path: $1"
fi
}
##############################################################################
mark_not_to_build () {
case $1 in
MCMS_DIR)
export BUILD_MCMS=FALSE
;;
CS_DIR)
export BUILD_CS=FALSE
;;
MPMX_DIR)
export BUILD_MPMX=FALSE
;;
MRMX_DIR)
export BUILD_MC=FALSE
export BUILD_AUDIO=FALSE
export BUILD_VIDEO=FALSE
;;
ENGINE_DIR)
export BUILD_ENGINE=FALSE
;;
esac
}
#############################################################################
echo_build_projects (){
echo
echo "building projects:"
echo "=================="
for build in ${BUILD_LIST[*]}
do
echo `env | grep BUILD_$build=`
done
echo
}
#############################################################################
test_var (){
VAR=`env | grep $1 | cut -d'=' -f2`
if [ "$VAR" == "" ]; then
LOOP="true"
while [[ "$LOOP" == "true" ]]; do
clear
echo -e "Please specify $1 directory:\n1. Use $1 from last build\n2. export $1=PATH (.../vob/MCMS/Main)"
read -p "Your choice [1/2]:"
case $REPLY in
1)
export_last $1
LOOP="false";
;;
2)
read -p "export $1="
export "$1"="$REPLY"
LOOP="false"
;;
*)
echo "Invalid choice..."
sleep 1
;;
esac
done
fi
}
#############################################################################
#Point Projects directories that were not export to 'last', and mark them not to be built
test_dir (){
OFFICIAL=`env | grep "OFFICIAL_DIR" | cut -d'=' -f2`
VAR=`env | grep $1 | cut -d'=' -f2`
#Test official build dir
if [ "$OFFICIAL" != "" ]; then
if [ -d "$OFFICIAL_DIR" ]; then
if [ "$VAR" == "" ]; then
export_official $1
mark_not_to_build $1
else
TMP=`env | grep $1 | cut -d'=' -f2 | grep NonStableBuild`
if [ "$TMP" != "" ]; then
mark_not_to_build $1
fi
fi
else
echo "OFFICIAL_DIR is invalid: $OFFICIAL_DIR"
exit 1
fi
else
#subproject
if [ "$VAR" == "" ]; then
echo "Please specify $1 directory by export $1=PATH (.../vob/MCMS/Main)"
exit 1
else
TMP=`env | grep $1 | cut -d'=' -f2 | grep NonStableBuild`
if [ "$TMP" != "" ]; then
mark_not_to_build $1
fi
fi
fi
}
################################ VARIABLES VERIFICATION ##################################
verify_variables () {
for var in ${DIR_LIST[*]}
do
test_dir $var
done
echo ""
echo "Verifying variables:"
echo "===================="
if [ -e $MCMS_DIR/Scripts/soft.sh ]
then
echo -n "MCMS_DIR is verified"
test_using_official $MCMS_DIR
else
echo "MCMS_DIR is invalid:" $MCMS_DIR
return 1
fi
if [ -e $CS_DIR/bin/loader ]
then
echo -n "CS_DIR is verified"
test_using_official $CS_DIR
else
echo "CS_DIR is invalid:" $CS_DIR
return 1
fi
if [ -e $MPMX_DIR/Script/runmfa.sh ]
then
echo -n "MPMX_DIR is verified"
test_using_official $MPMX_DIR
else
echo "MPMX_DIR is invalid:" $MPMX_DIR
return 1
fi
if [ -e $MRMX_DIR/mp*proxy ]
then
echo -n "MRMX_DIR is verified"
test_using_official $MRMX_DIR
else
echo "MRMX_DIR is invalid:" $MRMX_DIR
return 1
fi
if [ -e $ENGINE_DIR/Scripts/ ]
then
echo -n "ENGINE_DIR is verified"
test_using_official $ENGINE_DIR
else
echo "ENGINE_DIR is invalid:" $ENGINE_DIR
return 1
fi
}
################################## Make MCMS #############################
make_MCMS() {
cd $MCMS_DIR
if [[ "$KLOCWORK" == "YES" ]]; then
echo "This compilation will run KLOCWORK analyze!!!"
make active
/opt/polycom/soft_mcu/KW_local_analyze.sh MCMS_7_6_1S " " ./make.sh || echo "Klocwork - Nothing to analyze. "
return 0
fi
if [[ $? == 0 ]]; then
make active
./make.sh || return 1
else
return 1
fi
}
################################## Make CS #############################
make_CS() {
cd $CS_DIR
if [[ $? == 0 ]]; then
if [ -e $MCMS_DIR/CSFirstRun ]
then
echo "Compile the CS without -C"
./csmake || return 1
else
echo "Compile the CS with -C"
touch $MCMS_DIR/CSFirstRun
./csmake -C || return 1
fi
else
return 1
fi
}
################################## Make MediaCard #############################
make_MPMX() {
cd $MPMX_DIR
if [[ $? == 0 ]]; then
./_MPMXmake_ -x86 || return 1
./Script/build-x86_env.sh || return 1
else
return 1
fi
}
################################## Make MC #############################
make_MC() {
ln -sf $RMX1000_RPM_FILE /tmp/rmx1000.rpm
. $MCMS_DIR/Scripts/InstallRmx1000rpm.sh
#cd $MRMX_DIR/mermaid/
cd $MRMX_DIR/mp_proxy
if [[ $? == 0 ]]; then
make -j4 || return 1
else
return 1
fi
}
################################## Make AUDIO #############################
make_AUDIO() {
cd $MRMX_DIR/ampSoft/
if [[ $? == 0 ]]; then
echo "Compile audio"
make -j4 || return 1
else
return 1
fi
}
################################## Make VIDEO #############################
make_VIDEO() {
cd $MRMX_DIR/vmp/
if [[ $? == 0 ]]; then
echo "Compile video"
source $MRMX_DIR/vmp/ia64_pt
make -j8 || return 1
make install
else
return 1
fi
}
################################## Make ENGINE #############################
make_ENGINE() {
cd $ENGINE_DIR
if [[ "$KLOCWORK" == "YES" ]]; then
echo "This compilation will run KLOCWORK analyze!!!"
/opt/polycom/soft_mcu/KW_local_analyze.sh EngineMRM_7_6_1S " " make || echo "Klocwork - Nothing to analyze."
return 0
fi
if [[ "$FARM" == "YES" ]]; then
export DISTCC_DIR=/nethome/sagia/distcc
export MAKEPARM=-j36
export DISTCC_BIN=$DISTCC_DIR/bin/distcc
export PREMAKE=$DISTCC_DIR/bin/pump
unset DISTCC_HOSTS
fi
if [[ $? == 0 ]]; then
$PREMAKE make $MAKEPARM || return 1
else
return 1
fi
}
################################## MAKE All##################################
make_all_projects (){
if [ `whoami` == "root" ]
then
echo "You can't run this script as root!!!"
exit
fi
#If 'soft.sh make TARGET' is used, export only this TARGET as TRUE and the rest with FALSE
if [[ "$1" != "" ]]
then
for build in ${BUILD_LIST[*]}
do
if [ "$build" == $1 ]; then
export BUILD_$build=TRUE
else
export BUILD_$build=FALSE
fi
done
fi
echo_build_projects
#Loop to build each project
for build in ${BUILD_LIST[*]}
do
if [ `env | grep BUILD_$build= | cut -d'=' -f2` == TRUE ]; then
trace_start_build $build
make_$build
compile_result $? "BUILD_$build"
fi
done
compile_result 0 "ALL"
}
################################## MAKE CLEAN ##################################
make_clean (){
if [ `whoami` == "root" ]
then
echo "You can't run this script as root!!!"
exit
fi
#Cleaning
clean
# Building
echo "building all soft mcu process after clean"
make_all_projects
exit 0
}
################################## CLEAN ##################################
clean () {
if [ `whoami` == "root" ]
then
echo "You can't run this script as root!!!"
exit
fi
echo "cleaning soft mcu modules"
echo_build_projects
if [ "$BUILD_MCMS" == "TRUE" ]; then
cd $MCMS_DIR
./fast_clean.sh
fi
#cd $CS_DIR
#Force CS make clean by removing the following file:
if [ "$BUILD_CS" == "TRUE" ]; then
rm -f $MCMS_DIR/CSFirstRun
fi
if [ "$BUILD_MPMX" == "TRUE" ]; then
cd $MPMX_DIR
make clean
fi
if [ "$BUILD_MC" == "TRUE" ]; then
#cd $MRMX_DIR/mermaid/
cd $MRMX_DIR/mp_proxy
make clean
fi
if [ "$BUILD_AUDIO" == "TRUE" ]; then
cd $MRMX_DIR/ampSoft/
make clean
fi
if [ "$BUILD_VIDEO" == "TRUE" ]; then
cd $MRMX_DIR/vmp/
source ./ia64_pt
make clean
fi
if [ "$BUILD_ENGINE" == "TRUE" ]; then
cd $ENGINE_DIR
make clean
fi
}
################################## MAKE RPM ################################
make_rpm () {
if [ `whoami` == "root" ]
then
echo "You can't run this script as root!!!"
exit
fi
echo "make rpm for soft mcu modules"
echo_build_projects
if [ "$BUILD_MCMS" == "TRUE" ]; then
echo "Make MCMS RPM"
cd $MCMS_DIR
make active
./MakeRpm.sh no
fi
if [ "$BUILD_CS" == "TRUE" ]; then
echo "Make CS RPM"
cd $CS_DIR
./MakeRpm.sh no
fi
if [ "$BUILD_MPMX" == "TRUE" ]; then
echo "Make MPMX RPM"
cd $MPMX_DIR
./MakeRPM.sh no
fi
if [ "$BUILD_MC" == "TRUE" ]; then
echo "Make mp_proxy and amp RPM"
cd $MRMX_DIR/
./MakeRmx1000Rpm.sh yes
fi
if [ "$BUILD_AUDIO" == "TRUE" ]; then
echo "Make Audio(Amp) RPM"
cd $MRMX_DIR/ampSoft/
./MakeRPM.sh no
fi
if [ "$BUILD_VIDEO" == "TRUE" ]; then
echo "Make Video(Vmp) RPM"
cd $MRMX_DIR/vmp/
./MakeRPM.sh no
fi
if [ "$BUILD_ENGINE" == "TRUE" ]; then
echo "Make engine RPM"
cd $ENGINE_DIR
./MakeRPM.sh no
fi
}
################################## PRIVATE_BUILD ##################################
private_build(){
if [ -d "$OFFICIAL_DIR" ]; then
echo "Creating Private build:"
# Create private rpms
make_rpm
# Prepare dir
rm -rf ~/SoftMcu_PrivateBuild
mkdir -p ~/SoftMcu_PrivateBuild
# Copy original rpms
cp $OFFICIAL_DIR/SoftMcuRPMs/RPMs/*.rpm ~/SoftMcu_PrivateBuild/
# Copy specific rpms - per project
if [ "$BUILD_MCMS" == "TRUE" ]; then
rm ~/SoftMcu_PrivateBuild/Plcm-Mcms-*.i386.rpm
echo "Copy MCMS RPM"
cp ~/McmsRpmbuild/rpmbuild/RPMS/i386/Plcm-Mcms-*.i386.rpm ~/SoftMcu_PrivateBuild/
fi
if [ "$BUILD_CS" == "TRUE" ]; then
rm ~/SoftMcu_PrivateBuild/Plcm-Cs-*.i386.rpm
echo "Copy CS RPM"
cp ~/CsRpmBuild/rpmbuild/RPMS/i386/Plcm-Cs-*.i386.rpm ~/SoftMcu_PrivateBuild/
fi
if [ "$BUILD_MPMX" == "TRUE" ]; then
rm ~/SoftMcu_PrivateBuild/Plcm-Mpmx-*.i386.rpm
echo "Copy MPMX RPM"
cp ~/MediaCardRpm/rpmbuild/RPMS/i386/Plcm-Mpmx-*.i386.rpm ~/SoftMcu_PrivateBuild/
fi
if [ "$BUILD_MC" == "TRUE" ]; then
rm ~/SoftMcu_PrivateBuild/Plcm-Rmx1000-*.i386.rpm
rm ~/SoftMcu_PrivateBuild/Plcm-AmpSoft-*.i386.rpm
rm ~/SoftMcu_PrivateBuild/Plcm-VmpSoft-*.x86_64.rpm
rm ~/SoftMcu_PrivateBuild/Plcm-MpProxy-*.i386.rpm
echo "Copy MpProxy, amp and vmp RPM"
cp ~/Rmx1000Rpmbuild/rpmbuild/RPMS/i386/Plcm-Rmx1000-*.i386.rpm ~/SoftMcu_PrivateBuild/
cp ~/Rmx1000Rpmbuild/rpmbuild/RPMS/i386/Plcm-AmpSoft-*.i386.rpm ~/SoftMcu_PrivateBuild/
cp ~/Rmx1000Rpmbuild/rpmbuild/RPMS/x86_64/Plcm-VmpSoft-*.x86_64.rpm ~/SoftMcu_PrivateBuild/
cp ~/Rmx1000Rpmbuild/rpmbuild/RPMS/i386/Plcm-MpProxy-*.i386.rpm ~/SoftMcu_PrivateBuild/
fi
if [ "$BUILD_ENGINE" == "TRUE" ]; then
rm ~/SoftMcu_PrivateBuild/Plcm-EngineMRM-*.x86_64.rpm
echo "Copy engine RPM"
cp ~/EngineRpm/rpmbuild/RPMS/x86_64/Plcm-EngineMRM-*.x86_64.rpm ~/SoftMcu_PrivateBuild/
fi
echo -e ${GREEN}"Private build is ready at: $HOME/SoftMcu_PrivateBuild/"${NO_COLOR}
else
echo "OFFICIAL_DIR is invalid: $OFFICIAL_DIR"
exit 1
fi
}
################################## START ##################################
install_build(){
if [ `whoami` == "root" ]
then
echo "You can't run this script as root!!!"
exit 1
fi
if [[ $1 == "" ]]; then
echo "Usage: soft.sh install IP_ADDRESS"
exit 1
fi
# Validate dest address
ping -c 1 $1 &> /dev/null
if [[ $? != 0 ]]; then
echo -e ${RED}"$1 - Address is not reachable"${NO_COLOR}
exit 1
else
ssh root@$1 'rm -rf /tmp/RPMs; mkdir -p /tmp/RPMs; service soft_mcu stop'
echo "Copying rpm files to remote machine"
scp ~/SoftMcu_PrivateBuild/*.rpm root@$1:/tmp/RPMs/
echo "Installing remote machine"
#ssh root@$1 'if [[ `rpm -qa | grep "Plcm" ` != "" ]]; then rpm -e Plcm-SoftMcuMain-* Plcm-EngineMRM-* Plcm-UI_AIM-* Plcm-jsoncpp-* Plcm-libphp-* Plcm-httpd-* Plcm-VmpSoft-* Plcm-MpProxy-* Plcm-AmpSoft-* Plcm-Rmx1000-* Plcm-Mpmx-* Plcm-Cs-* Plcm-Ema-* Plcm-Mcms-*; fi; cd /tmp/RPMs; rpm -ivh Plcm-SoftMcuMain-* Plcm-EngineMRM-* Plcm-UI_AIM-* Plcm-jsoncpp-* Plcm-libphp-* Plcm-httpd-* Plcm-VmpSoft-* Plcm-MpProxy-* Plcm-AmpSoft-* Plcm-Rmx1000-* Plcm-Mpmx-* Plcm-Cs-* Plcm-Ema-* Plcm-Mcms-*; if [[ $? == 0 ]]; then echo "===== INSTALLATION FINISHED ===="; else echo "===== INSTALLATION FAILED ====";fi'
ssh root@$1 'if [[ `rpm -qa | grep "Plcm" ` != "" ]]; then rpm -e Plcm-SoftMcuMain-* Plcm-EngineMRM-* Plcm-UI_AIM-* Plcm-jsoncpp-* Plcm-VmpSoft-* Plcm-MpProxy-* Plcm-AmpSoft-* Plcm-Rmx1000-* Plcm-Mpmx-* Plcm-Cs-* Plcm-Ema-* Plcm-Mcms-* Plcm-SingleApache-*; fi; cd /tmp/RPMs; rpm -ivh Plcm-SoftMcuMain-* Plcm-EngineMRM-* Plcm-UI_AIM-* Plcm-jsoncpp-* Plcm-VmpSoft-* Plcm-MpProxy-* Plcm-AmpSoft-* Plcm-Rmx1000-* Plcm-Mpmx-* Plcm-Cs-* Plcm-Ema-* Plcm-Mcms-* Plcm-SingleApache-*; if [[ $? == 0 ]]; then echo "===== INSTALLATION FINISHED ===="; else echo "===== INSTALLATION FAILED ====";fi'
fi
}
################################## SETUP_VM ##################################
setup_sim_license_file(){
# select license file by product type
if [ "$LICENSE_FILE" == "" ]; then
PRODUCT_TYPE=`cat /mcms/ProductType`
if [ $PRODUCT_TYPE == "SOFT_MCU_EDGE" ]; then
LICENSE_FILE="VersionCfg/Keycodes_SoftMcuEdgeAxis_20_HD.cfs"
elif [ $PRODUCT_TYPE == "SOFT_MCU_CG" ]; then
LICENSE_FILE="VersionCfg/Keycodes_SoftMcuCG.cfs"
else
LICENSE_FILE="VersionCfg/Keycodes_SoftMcu_20_HD.cfs"
fi
fi
echo ""
echo Using License file for simulation: $LICENSE_FILE
mkdir -p /config/sysinfo
chmod a+w /config/sysinfo
cp $MCMS_DIR/$LICENSE_FILE /config/sysinfo/keycode.txt
chmod a+w /config/sysinfo/keycode.txt
}
################################## SETUP_VM ##################################
setup_vm_all_products (){
if [ `whoami` == "root" ]
then
echo "You can't run this script as root!!!"
exit
fi
cd $MCMS_DIR
stop
make active
setup_env
rm /tmp/mcms
ln -sf $MCMS_DIR /tmp/mcms
ln -sf $RMX1000_RPM_FILE /tmp/rmx1000.rpm
. $MCMS_DIR/Scripts/InstallRmx1000rpm.sh
export VM=YES
# Start of Block for Single Apache - kobig , remove this link in VM=YES
# rm -f /mcms/Bin/httpd 2> /dev/null
# ln -sf /usr/local/apache2/bin/httpd /mcms/Bin/
sudo /bin/rm /tmp/httpd.rest.conf
# cp -f /usr/local/apache2/conf/httpd.rest.conf /tmp
cp -f /mcms/StaticCfg/httpd.rest.conf /tmp
sed -i 's#^Include /tmp/httpd\.rest\.conf.*$##' /tmp/mcms/StaticCfg/httpd.conf.sim
sed -i 's/^User .*$//' /tmp/mcms/StaticCfg/httpd.conf.sim
chmod u+w /tmp/mcms/StaticCfg/httpd.conf.sim
echo "User `whoami`" >> /tmp/mcms/StaticCfg/httpd.conf.sim
mkdir /mcms/logs 2> /dev/null
chmod a+rwx /mcms/logs
echo "Include /tmp/httpd.rest.conf" >> /tmp/mcms/StaticCfg/httpd.conf.sim
echo "#!/bin/sh" > /mcms/Bin/ApacheModule
echo "CMD='sudo env LD_LIBRARY_PATH=/usr/local/apache2/lib:/mcms/Bin /mcms/Bin/httpd'" >> /mcms/Bin/ApacheModule
echo "CFG=/mcms/StaticCfg/httpd.conf.sim" >> /mcms/Bin/ApacheModule
echo "LOG=/tmp/startup_logs/DaemonProcessesLoad.log" >> /mcms/Bin/ApacheModule
echo "sleep 1" >> /mcms/Bin/ApacheModule
echo "\$CMD -f \$CFG 2>&1 | tee -a \$LOG" >> /mcms/Bin/ApacheModule
echo "while true; do" >> /mcms/Bin/ApacheModule
echo " sleep 10" >> /mcms/Bin/ApacheModule
echo " ps -e | grep -v grep | grep httpd >/dev/null || \$CMD -f \$CFG 2>&1 | tee -a \$LOG" >> /mcms/Bin/ApacheModule
echo "done" >> /mcms/Bin/ApacheModule
if [[ ! -e /mcms/EMA/htdocs ]]; then
ln -sf ${LAST_BUILD}/ema/ /mcms/EMA/htdocs
fi
#if [[ `ps -e | grep ApacheModule | grep -v grep` ]]; then
# :
#else
# nohup /mcms/Bin/ApacheModule 2> /dev/null &
#fi
# End Block for Single Apache
if [ "$CLEAN_CFG" != "NO" ]
then
export CLEAN_CFG=YES
echo "CONFIGURATION FILES WILL BE CLEANED"
fi
}
################################## START ##################################
start (){
if [ `whoami` == "root" ]
then
echo "You can't run this script as root!" | $LOG
exit 1
fi
# Gives 2 minutes to cool down in case of high load average.
# Exits if the load still exist.
export NUMBER_OF_CORES=`grep -c ^processor /proc/cpuinfo`
export LOAD_AVERAGE=`uptime | awk '{printf "%.0f\n",$(NF-2)}'`
export LOAD_THRESHOLD=1
if [[ $((LOAD_AVERAGE/NUMBER_OF_CORES)) -ge $LOAD_THRESHOLD ]]
then
echo "Load average $LOAD_AVERAGE / $NUMBER_OF_CORES >= $LOAD_THRESHOLD, wait for 2 minutes..." | $LOG
sleep 2m
LOAD_AVERAGE=`uptime | awk '{printf "%.0f\n",$(NF-2)}'`
if [[ $((LOAD_AVERAGE/NUMBER_OF_CORES)) -ge $LOAD_THRESHOLD ]]
then
echo "Load average $LOAD_AVERAGE / $NUMBER_OF_CORES >= $LOAD_THRESHOLD, exit." | $LOG
exit 1
fi
fi
#Launch the periodic MCU status logger
#echo "Launching Soft MCU Status Logger" | $LOG
if [[ "YES" == "${VM}" ]]; then
/mcms/Scripts/status_logger.sh soft.sh /tmp/startup_logs/MCU_Process_Status.log 15 60 &
fi
MFA_WITH_VALGRIND="NO"
if [[ "$1" != "" && "$1" == "mfa" ]]
then
MFA_WITH_VALGRIND="YES"
fi
export LD_LIBRARY_PATH=$MCMS_DIR/Bin:$CS_DIR/lib
export ENDPOINTSSIM=NO
export GIDEONSIM=NO
if [ "$CLEAN_CFG" != "YES" ]
then
echo "CONFIGURATION FILES WILL NOT BE CLEANED" | $LOG
export CLEAN_CFG=NO
fi
export CLEAN_LOG_FILES=NO
rm -f /tmp/httpd.pid
cd $MCMS_DIR
echo "Clean before start." | $LOG
Scripts/Cleanup.sh 2>&1 | $LOG
PRODUCT_TYPE=`cat /mcms/ProductType`
if [ -z $PRODUCT_TYPE ]; then
PRODUCT_TYPE="SOFT_MCU"
fi
echo "Start $PRODUCT_TYPE." | $LOG
export SOFT_MCU_FAMILY=YES
if [[ $PRODUCT_TYPE == "SOFT_MCU_MFW" ]]; then
export SOFT_MCU_MFW=YES
mkdir -p /mcms/EMA
elif [[ $PRODUCT_TYPE == "SOFT_MCU_EDGE" ]]; then
export SOFT_MCU_EDGE=YES
elif [[ "$PRODUCT_TYPE" == "GESHER" ]]; then
export GESHER=YES
echo "Gesher Bringing up eth0 first..."
Scripts/GesherUpEths.sh
echo "Run Gesher McmsStart.sh ..."
Scripts/GesherMcmsStart.sh &
elif [[ "$PRODUCT_TYPE" == "NINJA" ]]; then
export NINJA=YES
echo "Ninja Bringing up eth0 first..."
Scripts/GesherUpEths.sh
echo "Run Ninha McmsStart.sh ..."
Scripts/GesherMcmsStart.sh &
elif [[ "$PRODUCT_TYPE" == "SOFT_MCU_CG" ]]; then
export SOFT_MCU_CG=YES
else
export SOFT_MCU=YES
fi
echo -n $PRODUCT_TYPE > /tmp/EMAProductType.txt
echo -n NO > /tmp/JITC_MODE.txt
export MPL_SIM_FILE=VersionCfg/MPL_SIM_SWITCH_ONLY.XML
make active
echo "Start MCMS." | $LOG
if [[ "$1" != "" ]]
then
echo "#######################################" | $LOG
echo " Running $1 under Valgrind " | $LOG
echo "#######################################" | $LOG