-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.sh
244 lines (204 loc) · 7.33 KB
/
boot.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
#!/bin/sh
rm /var/* -rf
mkdir /var/run
mkdir /var/lock
#mkdir /tmp
#mount -t tmpfs tmpfs /tmp
#mkdir /run
#mount -t tmpfs tmpfs /run
export MTDBLOCK5_CONFIG_DIR=/mnt/mtd/configInfo
export CONFIG_DIR=/mnt/mtd/configInfo/Config
export FACTORY_CONFIG_DIR=/mnt/mtd/configInfo/factoryConfig
export DEFAULT_CONFIG_DIR=/mnt/mtd/default
export MTDBLOCK_LOG_DIR=/mnt/mtd/log
export LD_LIBRARY_PATH=/mnt/mtd/:$LD_LIBRARY_PATH
export QTDIR=/mnt/mtd/qte
export LD_LIBRARY_PATH=$QTDIR/directfb-lib:$LD_LIBRARY_PATH
#ko是å¦ä¸ºå‹ç¼©æ–‡ä»¶
if [ -f /mnt/mtd/modules.tar.lzma ]; then
cp /mnt/mtd/modules.tar.lzma /tmp/
cd /tmp/ && unlzma modules.tar.lzma && tar -xvf modules.tar && rm -rf modules.tar
export MODULES_PATH=/tmp/modules
else
export MODULES_PATH=/mnt/mtd/modules
fi
#å‡çº§
export UpgradeSh=/mnt/mtd/upgrade.sh
export UpdateStatus=/mnt/mtd/Update.dat
if [ -f $UpdateStatus ] ; then
sh ${UpgradeSh}
if [ $? -ne 0 ]; then
echo "need reboot"
exit -1;
fi
fi
#æ£å¸¸å¯åŠ¨
cd /mnt/mtd/
. ./mount_mtdblock.sh
echo "now start mount block"
if [ ! -d $MTDBLOCK5_CONFIG_DIR ]; then
mkdir $MTDBLOCK5_CONFIG_DIR
fi
if [ "x$CONFIG_MTDBLOCK" = "x" ] ; then
echo "config umount"
else
mount -t jffs2 $CONFIG_MTDBLOCK $MTDBLOCK5_CONFIG_DIR
fi
if [ ! -d $MTDBLOCK_LOG_DIR ]; then
mkdir $MTDBLOCK_LOG_DIR
fi
if [ "x$LOG_MTDBLOCK" = "x" ] ; then
echo "log umount"
else
mount -t jffs2 $LOG_MTDBLOCK $MTDBLOCK_LOG_DIR
fi
if [ ! -d $FACTORY_CONFIG_DIR ]; then
mkdir $FACTORY_CONFIG_DIR
fi
if [ ! -d $CONFIG_DIR ]; then
mkdir $CONFIG_DIR
fi
#出å‚é…ç½®ä¸å…¨ï¼Œ 设备ä¸å¯åŠ¨
if [ -f $FACTORY_CONFIG_DIR/OR_factoryConfig.xml ]; then
if [ ! -f $FACTORY_CONFIG_DIR/OR_systemInfo.xml ]; then
echo "$FACTORY_CONFIG_DIR/OR_systemInfo.xml not exist"
exit
fi
if [ ! -f $FACTORY_CONFIG_DIR/OR_runParameter.xml ]; then
echo "file $FACTORY_CONFIG_DIR/OR_runParameter.xml not exist"
exit
fi
#å‡çº§å第一次å¯åŠ¨,将工å‚é…置设置进默认é…ç½®
if [ ! -f /mnt/mtd/checkConfig ]; then
echo " ------------ setFactoryConfigToDefault --------"
cd /mnt/mtd/ && ./setFactoryConfigToDefault
fi
#当出å‚é…ç½®ä¸å˜åœ¨æ—¶å¤„ç†OR_systemInfo.xml OR_runParameter.xml
else
#下两文件ä¸å˜åœ¨åˆ™æ‹·è´ï¼Œå˜åœ¨åˆ™æ¯”较
if [ ! -f $FACTORY_CONFIG_DIR/OR_systemInfo.xml ]; then
cp $DEFAULT_CONFIG_DIR/OR_systemInfo.xml $FACTORY_CONFIG_DIR
else
diff $DEFAULT_CONFIG_DIR/OR_systemInfo.xml $FACTORY_CONFIG_DIR/OR_systemInfo.xml > /dev/null
if [ $? -ne 0 ]; then
cp $DEFAULT_CONFIG_DIR/OR_systemInfo.xml $FACTORY_CONFIG_DIR
fi
fi
if [ ! -f $FACTORY_CONFIG_DIR/OR_runParameter.xml ]; then
cp $DEFAULT_CONFIG_DIR/OR_runParameter.xml $FACTORY_CONFIG_DIR
else
diff $DEFAULT_CONFIG_DIR/OR_runParameter.xml $FACTORY_CONFIG_DIR/OR_runParameter.xml > /dev/null
if [ $? -ne 0 ]; then
cp $DEFAULT_CONFIG_DIR/OR_runParameter.xml $FACTORY_CONFIG_DIR
fi
fi
fi
#空æ¿ç¬¬ä¸€æ¬¡å¯åŠ¨æ—¶é…置版本å·æ–‡ä»¶ä¸å˜åœ¨
if [ ! -f $FACTORY_CONFIG_DIR/OR_configVersionInfo.xml ]; then
cp $DEFAULT_CONFIG_DIR/OR_configVersionInfo.xml $FACTORY_CONFIG_DIR
fi
#如æœéœ€è¦æ¢å¤å‡ºå‚设置
if [ -f /mnt/mtd/log/restoreCFG ] || [ -f /mnt/mtd/restoreCFG ] ; then
echo "restore factory settings by boot.sh."
cd $CONFIG_DIR/ && find ./ |grep -v OR_foreverInfo.xml | xargs rm -rf
#rm -rf $CONFIG_DIR/*
rm -rf /mnt/mtd/log/*
rm -rf /etc/resolv.conf
rm -f /mnt/mtd/restoreCFG
else
##如æœæ•°æ®åº“文件已æŸåï¼Œé‚£ä¹ˆåˆ é™¤æ•°æ®åº“(下é¢ä¼šæ‹·è´é»˜è®¤æ•°æ®åº“文件)
for dbfile in configInfo/Config/SystemDb.db3 log/AbnormalLog.db3 log/SysLog.db3
do
if [ -f /mnt/mtd/$dbfile.malformed ] ; then
nErrTime=`cat /mnt/mtd/$dbfile.malformed`
echo "/mnt/mtd/$dbfile is malformed, errTimes=$nErrTime"
if [ "$nErrTime" -ge 2 ] ; then
mv /mnt/mtd/$dbfile /mnt/mtd/$dbfile.bak
rm -f /mnt/mtd/$dbfile.malformed
fi
fi
done
fi
#默认é…ç½®ä¸config下é…置处ç†
filelist=`ls ${DEFAULT_CONFIG_DIR}`
for file in $filelist
do
if [ "$file" = "OR_systemInfo.xml" ]; then
echo "$file nothing to do "
elif [ "$file" = "OR_runParameter.xml" ]; then
echo "$file nothing to do "
elif [ "$file" = "OR_configVersionInfo.xml" ]; then
echo "$file nothing to do "
elif [ "$file" = "OR_clientConfig.xml" ]; then
echo "$file nothing to do "
elif [ "$file" = "OR_configParameter.xml" ]; then
diff $DEFAULT_CONFIG_DIR/OR_configParameter.xml $FACTORY_CONFIG_DIR/OR_configParameter.xml > /dev/null
if [ $? -ne 0 ]; then
cp $DEFAULT_CONFIG_DIR/OR_configParameter.xml $FACTORY_CONFIG_DIR
fi
else
if [ ! -f $CONFIG_DIR/$file ]; then
echo $file
cp -rf $DEFAULT_CONFIG_DIR/$file $CONFIG_DIR
fi
fi
done
diff $DEFAULT_CONFIG_DIR/OR_funcpane.xml $CONFIG_DIR/OR_funcpane.xml > /dev/null
if [ $? -ne 0 ]; then
cp $DEFAULT_CONFIG_DIR/OR_funcpane.xml $CONFIG_DIR
fi
diff $DEFAULT_CONFIG_DIR/data.db $CONFIG_DIR/data.db > /dev/null
if [ $? -ne 0 ]; then
cp $DEFAULT_CONFIG_DIR/data.db $CONFIG_DIR
fi
diff $DEFAULT_CONFIG_DIR/OR_supportLanguageInfo.xml $CONFIG_DIR/OR_supportLanguageInfo.xml > /dev/null
if [ $? -ne 0 ]; then
cp $DEFAULT_CONFIG_DIR/OR_supportLanguageInfo.xml $CONFIG_DIR
fi
if [ -f $DEFAULT_CONFIG_DIR/OR_defaultHardwareSpecifications.xml ]; then
diff $DEFAULT_CONFIG_DIR/OR_defaultHardwareSpecifications.xml $CONFIG_DIR/OR_defaultHardwareSpecifications.xml > /dev/null
if [ $? -ne 0 ]; then
cp $DEFAULT_CONFIG_DIR/OR_defaultHardwareSpecifications.xml $CONFIG_DIR
fi
fi
if [ ! -f /etc/resolv.conf ]; then
cp $DEFAULT_CONFIG_DIR/resolv.conf /etc/
fi
#å‡çº§å第一次å¯åŠ¨
if [ ! -f /mnt/mtd/checkConfig ]; then
cd $MODULES_PATH && ./load_before -i
cd /mnt/mtd/ && ./ConfigAdapter 1
cd $MODULES_PATH && ./load_before -r
touch /mnt/mtd/checkConfig
#web端logo定制
if [ -f $FACTORY_CONFIG_DIR/LoginContent.png ]; then
cp $FACTORY_CONFIG_DIR/LoginContent.png /mnt/mtd/Web/Css/Pictures/Login/LoginContent.png
fi
if [ -f $FACTORY_CONFIG_DIR/appName.png ]; then
cp $FACTORY_CONFIG_DIR/appName.png /mnt/mtd/Web/Css/Pictures/appName.png
fi
if [ -f $FACTORY_CONFIG_DIR/favicon.ico ]; then
cp $FACTORY_CONFIG_DIR/favicon.ico /mnt/mtd/Web/favicon.ico
fi
fi
#导入é…ç½®
if [ -f /mnt/mtd/IMPORT_TMP_WEB_CONFIG.data ]; then
cd $MODULES_PATH && ./load_before -i
cd /mnt/mtd/ && ./ConfigAdapter 2
cd $MODULES_PATH && ./load_before -r
fi
cd $MODULES_PATH && ./load -i
sleep 1
#防æ¢koå 用内å˜
if [ -f /mnt/mtd/modules.tar.lzma ]; then
####打包的时候就è¦å¤„ç†å¥½ï¼Œä¸èƒ½å†æ¯æ¬¡å¯åŠ¨æ—¶æ‹·è´ï¼ŒFlashç»ä¸èµ·é¢‘ç¹å†™
#mkdir /mnt/mtd/modules
#cp /tmp/modules/hifb.ko /mnt/mtd/modules/hifb.ko
#sync
rm -rf /tmp/modules
fi
/mnt/mtd/dep2.sh
#如æœæœªç»è¿‡å‡ºå‚é…置,默认å¯åŠ¨telnetd
if [ ! -f $FACTORY_CONFIG_DIR/OR_factoryConfig.xml ]; then
telnetd
fi