-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
897 lines (772 loc) · 28.7 KB
/
install
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
#!/bin/bash
#
###############################################################################
# #
# 华为终端数据卡linux 后台注册软件 #
# 版权属于华为技术有限公司,不得盗用,违者必究 #
# Huawei linux MobilePartner licensed software #
# Copyright (c) 2007-2008 by Huawei Tech. Corp. Ltd.. #
# 2008.7.8 #
# #
###############################################################################
#
BAKCURRENTPATH=`pwd`
SOFTWARENAME="airtel"
INSTALLWORKPATH="$(dirname "$0")"
CONFIG_FILE="/etc/datacard_config"
HOOK_FILE="/etc/pm/sleep.d"
USERDATA_PATH="/usr/local/hw_mp_userdata"
PPPD_PATH="/usr/local/hw_pppd"
FULLVERSION=23.015.02.11.284
SOFTWARENAMEINDESKTOP=$SOFTWARENAME
SOFTWARENAME=$(echo $SOFTWARENAME | sed s\#\ \#_\#g)
INSTALLPATH="/usr/local/${SOFTWARENAME}"
TEMPWORKPATH="/tmp/${SOFTWARENAME}_$$"
TEMPFILE="${SOFTWARENAME}_install_$PPID"
PRINTDAY=`date +%m/%d/%Y`
PRINTDETAILTIME=`date +%H:%M:%S`
PRINTWEEK=`date +%A`
PRINTTIME=`echo Date=$PRINTDAY '('$PRINTWEEK')' Time=$PRINTDETAILTIME`
INSTALLLOGFILE="/tmp/UTPSInstall.log"
#System Language
SYSLANG="$(echo $LANG | cut -d '.' -f 1)"
#Language String
LANGUAGESTRING[0]="zh"
LANGUAGESTRING[1]="en_US"
LANGUAGECODE[0]=0
LANGUAGECODE[1]=1
LANGCODE=${LANGUAGECODE[1]}
i=0
while [ ".${LANGUAGESTRING[${i}]}" != "." ]
do
if [ ${LANGUAGESTRING[${i}]} = "${SYSLANG}" ]
then
LANGCODE=${LANGUAGECODE[${i}]}
break
fi
i=`expr ${i} + 1`
done
unset i
BEGININSTALL="Install..."
CREATETEMPWORKSPACE="Create temp work directory..."
SOFTINSTALLPATH="Installation Path is :"
EXTRACTDATABIN="Extract data.bin to install directory..."
EXTRACTDATABINRESULT="Extract data.bin success!"
EXTRACTMPBIN="Extract MobilePartner.bin to install directory..."
EXTRACTMPBINRESULT="Extract MobilePartner.bin success!"
INSTALLINGVERSION="PC will install new version is"
INSTALLHIGHVERSION="An old version has been installed."
INSTALLSAMEVERSION="An same version has been installed."
INSTALLOLDERVERSION="An new version new has been installed."
CREATEINSTALLDIR="Create install directory ..."
PREPARECOPYFILES="Copy MobilePartner.bin,data.bin,7zr..."
PREPARECOPYFILESRESULT="Copy files success!"
EXECUTEDRIVER="Execute driver..."
CREATEDESKTOP="Create Desktop Shortcut..."
CREATEPROGRAMDESKTOP="Create ProgramGroup Shortcut..."
DELETEALLLOCALFILES="Delete all local files (tempfiles,tempdirectory)..."
ENDINSTALL="Install Success!"
LYouMustBeRoot[0]="您必须以root用户运行本安装程序"
LYouMustBeRoot[1]="You must run the process by root"
LPlsInputInstallPath[0]="请输入安装的绝对路径"
LPlsInputInstallPath[1]="Please input the absolute path for install"
LInstallPath[0]="安装路径"
LInstallPath[1]="install path"
LIllegal[0]="非法"
LIllegal[1]="illegal"
LNoFile[0]="找不到文件:"
LNoFile[1]="Can not find file: "
LCanNotCreateDir[0]="无法创建目录"
LCanNotCreateDir[1]="Can not create dir"
LMobilePartnerInstall[0]="${SOFTWARENAMEINDESKTOP}安装程序"
LMobilePartnerInstall[1]="${SOFTWARENAMEINDESKTOP} installer"
LStartInstallPartner[0]="开始安装后台, 请稍后..."
LStartInstallPartner[1]="Installing ${SOFTWARENAMEINDESKTOP}..."
LCompleteInstallPartner[0]="已经完成后台安装"
LCompleteInstallPartner[1]="install have completed, local path is"
LLocalPath[0]="本地安装路径"
LLocalPath[1]="Local path is"
LOverwriteInstalled[0]="已经安装有后台, 是否覆盖"
LOverwriteInstalled[1]="The software is exist. Do you want overwrite it"
LInstallJRE[0]="安装JRE"
LInstallJRE[1]="install JRE"
LInstallMP[0]="安装后台"
LInstallMP[1]="install ${SOFTWARENAMEINDESKTOP}"
LInstallAll[0]="安装JRE和后台"
LInstallAll[1]="install JRE and ${SOFTWARENAMEINDESKTOP}"
LQuitInstall[0]="退出"
LQuitInstall[1]="Exit"
LPlsSelect[0]="请选择:"
LPlsSelect[1]="Please select: "
LYouMustSelect[0]="你必须选择:"
LYouMustSelect[1]="You must select: "
LInstallEnd[0]="结束, 按任意键退出"
LInstallEnd[1]="Finished, press any key to exit"
LInstallingVersionOlderThenInstalled[0]="警告:正在安装的版本比系统中的版本旧。是否覆盖?"
LInstallingVersionOlderThenInstalled[1]="WARNING: The installing version is older than installed. Do you want to overwrite it"
LInstallingVersionLaterThenInstalled[0]="系统中存在旧版本。是否升级?"
LInstallingVersionLaterThenInstalled[1]="There is a older version in your system. Do you want to update it"
LInstalledVersion[0]="已安装版本:"
LInstalledVersion[1]="Installed version:"
LInstallingVersion[0]="正在安装版本:"
LInstallingVersion[1]="Installing version:"
LProgramRunning[0]="请先关闭程序再进行卸载。"
LProgramRunning[1]="Program is running, you need close it before uninstalling."
LCheckRun[0]="Program is running, you need close it before installing.";
LCheckRun[1]="程序正在运行,安装之前请先关闭."
LDeleteUserdata[0]="是否要删除所有的用户数据文件"
LDeleteUserdata[1]="Do you want to delete all user data files"
# /*yes or no 公共函数, yes返回0, no返回1*/
yes_or_no()
{
if [ ${#} -ne 2 ]
then
echo -e "yes_or_or: ${ErrorPara[${LANGCODE}]}"
return 1
fi
if [ "${2}" = "Y" ]
then
DEFPMPT="([Y]/N):\c "
DEFVAL="Y"
else
DEFPMPT="(Y/[N]):\c "
DEFVAL="N"
fi
echo -e "${1} ${DEFPMPT}"
read ANS
while [ "${ANS}" != "Y" -a "${ANS}" != "y" -a "${ANS}" != "N" -a "${ANS}" != "n" -a ! -z "${ANS}" ]
do
echo -e "${1} ${DEFPMPT}"
read ANS
done
: ${ANS:="${DEFVAL}"}
if [ "${ANS}" != "Y" -a "${ANS}" != "y" ]
then
unset ANS
return 1
fi
unset ASN
return 0
}
#检查启动安装脚本的用户是否为root用户
CheckID()
{
if [ `id | awk '{print $1}'` != "uid=0(root)" ]
then
echo -e "${LYouMustBeRoot[${LANGCODE}]}"
echo -e "\n${LInstallEnd[${LANGCODE}]}"
read -n 1
clear
exit
fi
}
#检查当前是否有后台正在运行
CheckRunning()
{
RUNJAR=`ps -ef |grep -v grep |grep MobilePartner.jar | awk '{print $2}'`
RUNBIN=`ps -ef |grep -v grep |grep MobilePartner.bin | awk '{print $2}'`
if [ "x${RUNJAR}" != "x" ]
then
echo -e "${LCheckRun[${LANGCODE}]}"
read RESP
exit
fi
if [ "x${RUNBIN}" != "x" ]
then
echo -e "${LCheckRun[${LANGCODE}]}"
read RESP
exit
fi
}
#检查相关文件,在硬盘上建立存放安装文件的临时目录,并拷贝安装文件到该目录
PreInstall()
{
echo -e "========================================================" >> ${INSTALLLOGFILE}
echo -e $PRINTTIME ' ' ${BEGININSTALL} >> ${INSTALLLOGFILE}
#检查安装包文件
if [ ! -f "${INSTALLWORKPATH}"/MobilePartner.bin ]
then
echo -e "${LNoFile[${LANGCODE}]}MobilePartner.bin"
exit
fi
if [ ! -f "${INSTALLWORKPATH}"/data.bin ]
then
echo -e "${LNoFile[${LANGCODE}]}data.bin"
exit
fi
if [ ! -f "${INSTALLWORKPATH}"/7zr ]
then
echo -e "${LNoFile[${LANGCODE}]}7zr"
exit
fi
if [ ! -d "${TEMPWORKPATH}" ]
then
mkdir ${TEMPWORKPATH}
echo -e $PRINTTIME ' ' ${CREATETEMPWORKSPACE} >> ${INSTALLLOGFILE}
fi
if [ ! -d "${TEMPWORKPATH}" ]
then
echo -e "\n${LCanNotCreateDir[${LANGCODE}]}: ${TEMPWORKPATH}"
exit
fi
#拷贝后台安装文件
echo -e $PRINTTIME ' ' ${PREPARECOPYFILES} >> ${INSTALLLOGFILE}
cp -f "${INSTALLWORKPATH}"/MobilePartner.bin ${TEMPWORKPATH}
cp -f "${INSTALLWORKPATH}"/data.bin ${TEMPWORKPATH}
cp -f "${INSTALLWORKPATH}"/7zr ${TEMPWORKPATH}
echo -e $PRINTTIME ' ' ${PREPARECOPYFILESRESULT} >> ${INSTALLLOGFILE}
chmod +x ${TEMPWORKPATH}/7zr
#拷贝安装脚本到硬盘上
cp -f "${INSTALLWORKPATH}"/install ${TEMPWORKPATH}
chmod a+x ${TEMPWORKPATH}/install
if [ -f $CONFIG_FILE ]
then
#获取版本信息
. $CONFIG_FILE
#获取系统中已经安装的版本号
VRVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f1`
BUILDVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f2`
DEVELOPVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f3`
SPVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f4`
CUSTOMIZEVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f5`
#获取正在安装的版本号
VRVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f1`
BUILDVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f2`
DEVELOPVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f3`
SPVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f4`
CUSTOMIZEVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f5`
#打印版本信息
echo "${LInstalledVersion[${LANGCODE}]} ${FullVersion}"
echo "${LInstallingVersion[${LANGCODE}]} ${FULLVERSION}"
echo -e $PRINTTIME ' ' "the installed version is " $FullVersion >> ${INSTALLLOGFILE}
echo -e $PRINTTIME ' ' "the installing version is " $FULLVERSION >> ${INSTALLLOGFILE}
#检查已经安装的版本是否更新
while [ 1 ]
do
#比较VR版本号,不相同则提示用户覆盖安装
if [ $VRVERSIONINSTALLED -ne $VRVERSIONINSTALLING ]
then
InstallDifferentVersionPrompt
break
fi
#比较C版本号,不相同则提示用户覆盖安装
if [ $CUSTOMIZEVERSIONINSTALLED -ne $CUSTOMIZEVERSIONINSTALLING ]
then
InstallDifferentVersionPrompt
break
fi
#比较B版本号
if [ $BUILDVERSIONINSTALLED -gt $BUILDVERSIONINSTALLING ]
then
#如果已安装的B版本号较新,则提示用户已经安装了较新的后台版本,是否继续
InstallOlderVersionPrompt
break
elif [ $BUILDVERSIONINSTALLED -lt $BUILDVERSIONINSTALLING ]
then
#如果已安装的B版本号较老,不需要继续比较D版本和SP版本,直接覆盖安装
InstallLaterVersionPrompt
break
fi
#比较D版本号
if [ $DEVELOPVERSIONINSTALLED -gt $DEVELOPVERSIONINSTALLING ]
then
#如果已安装的D版本号较新,则提示用户已经安装了较新的后台版本,是否继续
InstallOlderVersionPrompt
break
elif [ $DEVELOPVERSIONINSTALLED -lt $DEVELOPVERSIONINSTALLING ]
then
#如果已安装的D版本号较老,不需要继续比较SP版本,直接覆盖安装
InstallLaterVersionPrompt
break
fi
#比较SP版本号
if [ $SPVERSIONINSTALLED -gt $SPVERSIONINSTALLING ]
then
#如果已安装的SP版本号较新,则提示用户已经安装了较新的后台版本,是否继续
InstallOlderVersionPrompt
break
elif [ $SPVERSIONINSTALLED -lt $SPVERSIONINSTALLING ]
then
#如果已安装的SP版本号较老,直接覆盖安装
InstallLaterVersionPrompt
break
fi
#走到这表示所有版本号一致,给出提示是否覆盖
InstallSameVersionPrompt
break
done
INSTALLPATH=`egrep "^path=" $CONFIG_FILE | awk -F '=' '{print $2}'`
else
#输入安装目录
echo -e "\n ${LPlsInputInstallPath[${LANGCODE}]}[${INSTALLPATH}]: \c"
read ANS
: ${ANS:="${INSTALLPATH}"}
INSTALLPATH=${ANS}
#检查目录的合法性
if [[ ${INSTALLPATH} != /* ]]
then
echo -e "\n${LInstallPath[${LANGCODE}]} ${LIllegal[${LANGCODE}]}"
DisplayEndMsg
exit
fi
#使安装目录合理化
if [ -d "${INSTALLPATH}" ]
then
INSTALLPATH=${INSTALLPATH}/${SOFTWARENAME}
fi
fi
#创建安装目录
if [ ! -d "${INSTALLPATH}" ]
then
mkdir ${INSTALLPATH}
echo -e $PRINTTIME ' ' ${CREATEINSTALLDIR} >> ${INSTALLLOGFILE}
fi
if [ ! -d "${INSTALLPATH}" ]
then
echo -e "\n${LCanNotCreateDir[${LANGCODE}]}: ${INSTALLPATH}"
DisplayEndMsg
exit
fi
echo -e "\n${LLocalPath[${LANGCODE}]}: ${INSTALLPATH}"
echo -e $PRINTTIME ' ' ${SOFTINSTALLPATH} ${INSTALLPATH} >> ${INSTALLLOGFILE}
echo -e $PRINTTIME ' ' ${INSTALLINGVERSION} ${FULLVERSION} >> ${INSTALLLOGFILE}
}
InstallLaterVersionPrompt()
{
#新版本,提示是否升级
yes_or_no "\n${LInstallingVersionLaterThenInstalled[${LANGCODE}]}?" Y
if [ ${?} -ne 0 ]
then
DisplayEndMsg
exit
fi
echo -e $PRINTTIME ' ' $INSTALLHIGHVERSION >> ${INSTALLLOGFILE}
}
InstallSameVersionPrompt()
{
#如果以前已经安装过后台则提示是否覆盖
yes_or_no "\n${LOverwriteInstalled[${LANGCODE}]}?" Y
if [ ${?} -ne 0 ]
then
DisplayEndMsg
exit
fi
echo -e $PRINTTIME ' ' $INSTALLSAMEVERSION >> ${INSTALLLOGFILE}
}
InstallOlderVersionPrompt()
{
#安装的版本比系统中的版本旧,给出提示
yes_or_no "\n${LInstallingVersionOlderThenInstalled[${LANGCODE}]}?" N
if [ ${?} -ne 0 ]
then
DisplayEndMsg
exit
fi
echo -e $PRINTTIME ' ' $INSTALLOLDERVERSION >> ${INSTALLLOGFILE}
}
InstallDifferentVersionPrompt()
{
#如果以前已经安装过后台则提示是否覆盖
yes_or_no "\n${LOverwriteInstalled[${LANGCODE}]}?" Y
if [ ${?} -ne 0 ]
then
DisplayEndMsg
exit
fi
}
#安装后台
InstallMobilePartner()
{
# added to set the library path
# DTS2011042605304 begin
unset LD_LIBRARY_PATH
#echo -e "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${INSTALLPATH} \n export LD_LIBRARY_PATH \n" > ${HOME}/.bash_profile
# DTS2011042605304 end
echo -e -n "\n${LStartInstallPartner[${LANGCODE}]}"
cd "${INSTALLPATH}"
#在安装路径下解压缩安装包
# tar jxf ${TEMPWORKPATH}/MobilePartner.tar.bz2 >/dev/null 2>&1
echo -e $PRINTTIME ' ' ${EXTRACTMPBIN} >> ${INSTALLLOGFILE}
"${TEMPWORKPATH}/7zr" x -y ${TEMPWORKPATH}/MobilePartner.bin >/dev/null 2>&1
echo -e $PRINTTIME ' ' ${EXTRACTMPBINRESULT} >> ${INSTALLLOGFILE}
echo -e $PRINTTIME ' ' ${EXTRACTDATABIN} >> ${INSTALLLOGFILE}
"${TEMPWORKPATH}/7zr" x -y ${TEMPWORKPATH}/data.bin >/dev/null 2>&1
echo -e $PRINTTIME ' ' ${EXTRACTDATABINRESULT} >> ${INSTALLLOGFILE}
# chmod -R a+w "${INSTALLPATH}"/userdata
# chmod -R a+w "${INSTALLPATH}"/log
chmod -R a+w "${INSTALLPATH}"/config
PromoteDeleteUserData
#运行驱动工具安装脚本
chmod -R a+x ./driver/*
#./driver/install ${INSTALLPATH} >/dev/null 2>&1
echo -e $PRINTTIME ' ' ${EXECUTEDRIVER} >> ${INSTALLLOGFILE}
./driver/install ${INSTALLPATH} .bin
#安装CommMgr并设置为系统服务
# chmod +x ./CommMgr/*
# cd CommMgr
# ./install_CommMgr ${INSTALLPATH} >/dev/null 2>&1
# cd ..
#copy相关文件到相应目录
#拷贝拨号相关文件
chmod a+x ./sbin/*
chmod -R a+w ./hw_pppd
chmod -R a+x ./hw_pppd
# ubuntu10.10 cann't modem connect begin
./hw_pppd/sbin/install_pppd
rm -rf ./hw_pppd/sbin/install_pppd
rm -rf /usr/local/hw_pppd
# ubuntu10.10 cann't modem connect end
cp -rf ./hw_pppd /usr/local/
#copy QT libs to Mobile Partner directory
cp -lrf ${INSTALLPATH}/qtlib/lib*.so* ${INSTALLPATH}
#copy在线升级需要的动态库文件到相应目录
#copy only when UpdateDog directory exists
if [ -d ${INSTALLPATH}/UpdateDog ]
then
cp -lrf ${INSTALLPATH}/qtlib/lib*.so* ${INSTALLPATH}/UpdateDog
cp -lrf ${INSTALLPATH}/plugins/imageformats/libqgif.so ${INSTALLPATH}/UpdateDog/plugins/imageformats
cp -lrf ${INSTALLPATH}/plugins/imageformats/libqico.so ${INSTALLPATH}/UpdateDog/plugins/imageformats
fi
#uncommenting this to create /usr/local/hw_mobile_userdata/Mobile_Partner
#拷贝用户数据文件夹
if [ ! -d ${USERDATA_PATH} ]
then
mkdir $USERDATA_PATH
mkdir ${USERDATA_PATH}/${SOFTWARENAME}
mkdir ${USERDATA_PATH}/${SOFTWARENAME}/userdata
# do not create userdata directory.
# cp -rf ./userdata ${USERDATA_PATH}/${SOFTWARENAME}
chmod -R a+w ${USERDATA_PATH}
chmod -R a+r ${USERDATA_PATH}
else
#如果存在相同软件名称的用户数据,不覆盖
if [ ! -d ${USERDATA_PATH}/${SOFTWARENAME} ]
then
mkdir ${USERDATA_PATH}/${SOFTWARENAME}
mkdir ${USERDATA_PATH}/${SOFTWARENAME}/userdata
# do not create userdata directory.
# cp -rf ./userdata ${USERDATA_PATH}/${SOFTWARENAME}
chmod -R a+w ${USERDATA_PATH}
chmod -R a+r ${USERDATA_PATH}
else
if [ ! -d ${USERDATA_PATH}/${SOFTWARENAME}/userdata ]
then
mkdir ${USERDATA_PATH}/${SOFTWARENAME}/userdata
chmod -R a+w ${USERDATA_PATH}
chmod -R a+r ${USERDATA_PATH}
fi
fi
fi
chmod -R a+rwx ${USERDATA_PATH}/${SOFTWARENAME}
# create userdata/log directory for ui.
# mkdir -p ${USERDATA_PATH}/${SOFTWARENAME}/log
#修改sudoers文件
grep -v "MobilePartner.sh" /etc/sudoers >/tmp/${TEMPFILE} 2>&1
DELETECOMMENT="delete requiretty for hw_mobile"
REQUIRETTY=`grep "${DELETECOMMENT}" /tmp/${TEMPFILE}`
if [ "x${REQUIRETTY}" != "x" ]
then
REQUIRETTY=`echo "${REQUIRETTY}" | awk -F ',' '{printf $2}'`
else
REQUIRETTY=`grep "requiretty" /tmp/${TEMPFILE}`
if [ "x${REQUIRETTY}" != "x" ]
then
sed -i "s/${REQUIRETTY}/# ,${REQUIRETTY},${DELETECOMMENT}/g" /tmp/${TEMPFILE} 2>/dev/null
fi
fi
echo -e "ALL ALL=(ALL) NOPASSWD:ALL" >> /tmp/${TEMPFILE}
# added a new batch file
# added to generate .bin file and to give access permissions in user mode: Begin
# exec ${INSTALLPATH}/MobilePartner.bin will now be put after the special steps for each distro.
#echo -e "#!/bin/bash \n LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${INSTALLPATH} \n export LD_LIBRARY_PATH \n export PATH=/sbin:$PATH \n sudo LD_LIBRARY_PATH=${INSTALLPATH} \n exec ${INSTALLPATH}/MobilePartner.bin" > ${INSTALLPATH}/MobilePartner_Bat
#DTS2010072902594 Xserver path add to PATH
echo -e "#!/bin/bash \n LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${INSTALLPATH} \n export LD_LIBRARY_PATH \n export PATH=/usr/bin/X11:/usr/X11R6/bin:/sbin:$PATH \n sudo LD_LIBRARY_PATH=${INSTALLPATH} \n" > ${INSTALLPATH}/MobilePartner_Bat
#DTS2010072902594 modify end
mv ${INSTALLPATH}/MobilePartner ${INSTALLPATH}/MobilePartner.bin
mv ${INSTALLPATH}/MobilePartner_Bat ${INSTALLPATH}/MobilePartner
chmod a+x ${INSTALLPATH}/MobilePartner
chmod a+x ${INSTALLPATH}/MobilePartner.bin
chmod 777 -R ${INSTALLPATH}/*
CURRENT_VERSION=$(grep VALUE "${INSTALLPATH}/SysConfig.dat" | head -n1 | cut -d = -f2 | tr -d "\015")
VERSION_TO_REPLACE=$(grep version= "${INSTALLPATH}/RunInfo.ini" | head -n1)
sed -e 's/'"${VERSION_TO_REPLACE}"'/version='"${CURRENT_VERSION}"'/' "${INSTALLPATH}/RunInfo.ini" > RunInfo.tmp
mv -f RunInfo.tmp ${INSTALLPATH}/RunInfo.ini
CURRENT_OPERATOR=$(grep operator "${INSTALLPATH}/SysConfig.dat" | head -n1 | cut -d = -f2 | tr -d "\015")
OPERATOR_TO_REPLACE=$(grep operator= "${INSTALLPATH}/RunInfo.ini" | head -n1)
sed -e 's/'"${OPERATOR_TO_REPLACE}"'/operator='"${CURRENT_OPERATOR}"'/' "${INSTALLPATH}/RunInfo.ini" > RunInfo.tmp
mv -f RunInfo.tmp ${INSTALLPATH}/RunInfo.ini
# added to generate .bin file and to give access permissions in user mode: End
cp -f /tmp/${TEMPFILE} /etc/sudoers
echo -e $PRINTTIME ' ' "active language is " $SYSLANG >> ${INSTALLLOGFILE}
#编辑并创建桌面启动图标和开始菜单启动图标
sed "s#\${HW_SOFTWARENAME}#${SOFTWARENAMEINDESKTOP}#g" ./MobilePartner.desktop > /tmp/${TEMPFILE} 2>/dev/null
sed "s#\${HW_INSTALLPATH}#${INSTALLPATH}#g" /tmp/${TEMPFILE} > ./MobilePartner.desktop 2>/dev/null
echo -e $PRINTTIME ' ' ${CREATEDESKTOP} >> ${INSTALLLOGFILE}
if [ -d /root/Desktop ]
then
cp -f ./MobilePartner.desktop /root/Desktop
else
cp -f ./MobilePartner.desktop /root
fi
echo -e $PRINTTIME ' ' ${CREATEPROGRAMDESKTOP} >> ${INSTALLLOGFILE}
cp -f ./MobilePartner.desktop /usr/share/applications
#编辑并创建开始菜单卸载图标
sed "s#\${HW_SOFTWARENAME}#${SOFTWARENAMEINDESKTOP}#g" ./UninstallMobilePartner.desktop > /tmp/${TEMPFILE} 2>/dev/null
sed "s#\${HW_INSTALLPATH}#${INSTALLPATH}#g" /tmp/${TEMPFILE} > ./UninstallMobilePartner.desktop 2>/dev/null
cp -f ./UninstallMobilePartner.desktop /usr/share/applications
#编辑并创建运行脚本
echo -e "#!/bin/bash" > ./MobilePartner.sh
# for Ubuntu
UBUNTURELEASE=`grep Ubuntu /etc/issue 2>&1 | awk -F ' ' '{printf $1}'`
if [ "x${UBUNTURELEASE}" = "xUbuntu" ]
then
#DTS2010123003200 begin Refresh the Ubunto Menu Items After install
if [ -f /usr/share/gnome-menus/update-gnome-menus-cache ]
then
UpdateMenuForUbunto
fi
#DTS2010123003200 end
if [ ! -d /usr/share/fonts/truetype/arphic ]
then
mkdir -p /usr/share/fonts/truetype/arphic
fi
fi
# for Debian
DEBIANRELEASE=`grep Debian /etc/issue 2>&1 | awk -F ' ' '{printf $1}'`
if [ "x${DEBIANRELEASE}" = "xDebian" ]
then
if [ ! -d /usr/share/fonts/truetype/arphic ]
then
mkdir -p /usr/share/fonts/truetype/arphic
fi
fi
# for OpenSuSE
if [ -f /etc/SuSE-release ]
then
if [ ! -d /usr/share/fonts/truetype ]
then
mkdir -p /usr/share/fonts/truetype
fi
# echo -e "export DISPLAY=:0" >> ./MobilePartner.sh
#DTS2010062201326 modify begin
#DTS2013081206108 modify begin
#echo -e "export DISPLAY=:0" >> ${INSTALLPATH}/MobilePartner
echo -e "export DISPLAY=\$1" >> ${INSTALLPATH}/MobilePartner
#DTS2013081206108 modify end
fi
#DTS2010122702428 modify begin
# for ALTLinux
if [ -f /etc/altlinux-release ]
then
echo -e "export DISPLAY=:0" >> ${INSTALLPATH}/MobilePartner
fi
#DTS2010122702428 modify end
if [ ! -e /usr/bin/sudo ]
then
echo "There is no sudo command in your system,you'd better run the software by root"
echo "Press any key to continue..."
read -n 1
echo -e "#!/bin/bash \n ${INSTALLPATH}/MobilePartner \${DISPLAY}" > ${INSTALLPATH}/ReadDisplay
else
#DTS2013111408258 modify begin
if [ -f /etc/SuSE-release ]
then
echo -e "#!/bin/bash \n xhost +local:\n sudo ${INSTALLPATH}/MobilePartner \${DISPLAY}" > ${INSTALLPATH}/ReadDisplay
else
echo -e "#!/bin/bash \n sudo ${INSTALLPATH}/MobilePartner \${DISPLAY}" > ${INSTALLPATH}/ReadDisplay
fi
#DTS2013111408258 modify end
fi
chmod +x ${INSTALLPATH}/ReadDisplay
#DTS2010062201326 modify end
#insert hook
if [ -d /etc/pm/sleep.d ]
then
cp -f ${INSTALLPATH}/sbin/67hw_hook /etc/pm/sleep.d
chmod +x /etc/pm/sleep.d/67hw_hook
fi
# for jre compatibility
echo -e "export LIBXCB_ALLOW_SLOPPY_LOCK=1" >> ./MobilePartner.sh
# added for executing MobilePartner.bin file from MobilePartner.sh file: Begin
echo -e "APPDIR=${INSTALLPATH}" >> ./MobilePartner.sh
echo -e "cd \${APPDIR}" >> ./MobilePartner.sh
echo -e "\${APPDIR}/MobilePartner.bin &" >> ./MobilePartner.sh
echo -e "exec ${INSTALLPATH}/MobilePartner.bin" >> ${INSTALLPATH}/MobilePartner
# added for executing MobilePartner.bin file from MobilePartner.sh file: End
chmod +x ./MobilePartner.sh
chmod a+x ./MobilePartner
#编辑并创建卸载脚本
sed -i "s/{LYouMustBeRoot}/${LYouMustBeRoot[${LANGCODE}]}/g" ./UninstallMobilePartner
sed -i "s/{LInstallEnd}/${LInstallEnd[${LANGCODE}]}/g" ./UninstallMobilePartner
sed -i "s/{LProgramRunning}/${LProgramRunning[${LANGCODE}]}/g" ./UninstallMobilePartner
sed -i "s#{HOOK_FILE}#${HOOK_FILE}#g" ./UninstallMobilePartner
sed -i "s#{INSTALLPATH}#${INSTALLPATH}#g" ./UninstallMobilePartner
sed -i "s#{CONFIG_FILE}#${CONFIG_FILE}#g" ./UninstallMobilePartner
if [ "x${REQUIRETTY}" != "x" ]
then
sed -i "s/{REQUIRETTY}/${REQUIRETTY}/g" ./UninstallMobilePartner
sed -i "s/{DELETECOMMENT}/${DELETECOMMENT}/g" ./UninstallMobilePartner
else
grep -v {REQUIRETTY} ./UninstallMobilePartner > /tmp/${TEMPFILE}
cp -f /tmp/${TEMPFILE} ./UninstallMobilePartner
fi
chmod +x ./UninstallMobilePartner
DonePrompt "${LStartInstallPartner[${LANGCODE}]}"
#echo -e "\n${SOFTWARENAMEINDESKTOP} ${LCompleteInstallPartner[${LANGCODE}]} ${INSTALLPATH}"
#After install succeed, create a new file to let onlineupdate know it's finished
#This file should be delete by onlineupdate program
touch "${USERDATA_PATH}/${SOFTWARENAME}/userdata/install.flg"
#清除本地文件
# rm -rf ./userdata
rm -rf ./hw_pppd
rm -rf ./*.desktop
rm -f /tmp/${TEMPFILE}
rm -rf ${TEMPWORKPATH}
echo -e $PRINTTIME ' ' ${DELETEALLLOCALFILES} >> ${INSTALLLOGFILE}
#DTS2010062201326 add begin
chmod 777 ${INSTALLPATH}
#DTS2010062201326 add end
}
DonePrompt()
{
LOGCHARNUM=`echo "$1" | wc -m`
TERMCHARNUM=`stty size | awk -F ' ' '{printf $2}'`
LOGCHARNUM=`expr $TERMCHARNUM - $LOGCHARNUM`
echo "[ done ] " | awk '{printf "%"'"$LOGCHARNUM"'"s", $0}'
echo -e ""
}
# /*提供选择语言*/
SelectLanguage()
{
while :
do
case ${LANGCODE} in
0)
echo -e "\n\t1. 简体中文"
echo -e "\t2. 英文"
echo -e "\n\t请选择语言: [1]\c"
read RESP
: ${RESP:="1"}
;;
*)
echo -e "\n\t1. Simplified Chinese"
echo -e "\t2. English"
echo -e "\n\tPlease select Language: [2]\c"
read RESP
: ${RESP:="2"}
;;
esac
case ${RESP} in
[1,2])
LANGCODE=`expr ${RESP} - 1`
return ${LANGCODE}
;;
*)
case ${LANGCODE} in
0)
echo -e - "\n\t你必须选择: 1, 2\n"
;;
*)
echo -e "\n\tPlease select: 1, 2\n"
;;
esac
;;
esac
done
}
# /*显示程序启动时的信息*/
DisplayStartMsg()
{
clear
}
# /*显示程序结束时的信息*/
DisplayEndMsg()
{
cd "${BAKCURRENTPATH}"
rm -rf "${TEMPWORKPATH}"
echo -e "\n${LInstallEnd[${LANGCODE}]}"
echo -e $PRINTTIME ' ' ${ENDINSTALL} >> ${INSTALLLOGFILE}
echo -e "========================================================" >> ${INSTALLLOGFILE}
read -n 1
clear
}
GenConfigFile()
{
cd $INSTALLPATH
echo "path=$INSTALLPATH" > $CONFIG_FILE
#DTS2013081206108 modify begin
echo "name=ReadDisplay" >> $CONFIG_FILE
echo "Exec=$INSTALLPATH/ReadDisplay" >> $CONFIG_FILE
#DTS2013081206108 modify end
echo "FullVersion=$FULLVERSION" >> $CONFIG_FILE
}
#DTS2010123003200 begin Refresh the Ubunto Menu Items After install
UpdateMenuForUbunto()
{
for CACHE_FILE in ls /usr/share/applications/desktop.*.cache
do
if [ -f ${CACHE_FILE} ]; then
aa=`ls -l ${CACHE_FILE}|awk '{print substr($1, 2)}'|sed 's/-/0/g'|sed 's/r/1/g'|sed 's/w/1/g'|sed 's/x/1/g'`
chmod 777 ${CACHE_FILE}
/usr/share/gnome-menus/update-gnome-menus-cache /usr/share/applications/ > ${CACHE_FILE}
bb=$(echo "obase=8;ibase=2;$aa"|bc)
chmod ${bb} ${CACHE_FILE}
fi
done
}
#DTS2010123003200 end Refresh the Ubunto Menu Items After install
#begin DTS2011052404155 promote user to delete the uerdata files
PromoteDeleteUserData()
{
REMOVE_DATA=$(grep RemoveUserData "${INSTALLPATH}/SysConfig.dat" | head -n1 | cut -d = -f2 | tr -d "\015")
if [ "xtrue" = "x${REMOVE_DATA}" ]
then
if [ -f ${USERDATA_PATH}/${SOFTWARENAME}/userdata/UserSetting.xml ]
then
yes_or_no "\n${LDeleteUserdata[${LANGCODE}]}?" N
if [ ${?} -ne 1 ]
then
rm -fr ${USERDATA_PATH}/${SOFTWARENAME}/userdata
fi
fi
fi
}
#end DTS2011052404155 promote user to delete the uerdata files
clear
CheckID
CheckRunning
#SelectLanguage
DisplayStartMsg
#当让用户选择安装时,如下部分代码到应该放到while循环中
PreInstall
InstallMobilePartner
GenConfigFile
#echo "Download Programs finished!" > "$INSTALLPATH/lib/UpdateInstall/inputLog.txt"
DisplayEndMsg
exit 0
#不让用户选择安装,如下代码无效
while :
do
echo -e - "***\t\t${LMobilePartnerInstall[${LANGCODE}]}\t\t***\n"
echo -e - "${LPlsSelect[${LANGCODE}]}\n"
echo -e - "\t1) ${LInstallMP[${LANGCODE}]}"
echo -e - "\t0) ${LQuitInstall[${LANGCODE}]}\n"
echo -e - "Choice: [0]\c"
read RESP
: ${RESP:="0"}
case ${RESP} in
1)
PreInstall
InstallJRE
InstallMobilePartner
GenConfigFile
;;
0)
DisplayEndMsg
exit 0
;;
*)
echo -e - "${LYouMustSelect[${LANGCODE}]}1, 0"
;;
esac
done