-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp_Update_V2.5.sh
executable file
·365 lines (339 loc) · 7.99 KB
/
App_Update_V2.5.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
#!/bin/sh
backup_dir="/home/work/backup/backup_V2.4_app"
update_dir="/home/work/update/update_V2.5_app"
function file_backup()
{
if [ ! -d $backup_dir ];then
echo "[Creating $backup_dir]"
mkdir -p $backup_dir
if [ $? != 0 ]; then
return
fi
fi
cd /home/das_uq/
if [ $? != 0 ]; then
return
fi
echo "Creating tarball..."
if [ -f $backup_dir/App_V2.4.tar.gz ]; then
echo "[ERROR: $backup_dir/App_V2.4.tar.gz already exist!]"
return
fi
tar czvf $backup_dir/App_V2.4.tar.gz bin/ lib/ etc/ tools/
ls -l $backup_dir/App_V2.4.tar.gz
echo "[files back check OK?,press 'y' or 'n' to continue!]"
while true; do
read aa;
if [ -z $aa ];then
echo "[please input 'y' or 'n'] ";
elif [ $aa == 'n' ];then
echo "[ERROR:program teminated,please check again]"
exit 0;
elif [ $aa == 'y' ];then
echo "[file backup check finished,you can do [2.file update check] next!]";
break
else
echo "[please input 'y' or 'n' ]";
fi
done
}
function update_file_check()
{
echo "[update files check......]"
echo "[including quantity and size---]"
echo "[1 files should be in /home/work/update/update_V2.5_web;]"
cd /home/work/update/update_V2.5_web >/dev/null 2>&1
if [ $? != 0 ];then
echo "[folder '/home/work/update/update_V2.5_web' not found,please do the preparation first"
return
fi
ls -l /home/work/update/update_V2.5_web
echo " "
quantity=`find /home/work/update/update_V2.5_web -type f| wc -l`
size=`du -cb /home/work/update/update_V2.5_web/*|grep total|awk -F " " '{print$1}'`
echo "[tolal quantity:$quantity]"
echo "[total size:$size]"
echo "[update files check OK? press 'y' or 'n' to continue]"
while true; do
read ba;
if [ -z $ba ];then
echo "[please input 'y' or 'n'] ";
elif [ $ba == 'n' ];then
echo "[ERROR:program teminated,please check up files again]"
break ;
elif [ $ba == 'y' ];then
echo "[update files check finished,you can do [owner change] next!]";
echo " "
echo " "
break
else
echo "[please input 'y' or 'n' to continue] ";
fi
done
}
function owner_change()
{
echo "[owner change......]"
cd /home/work/update/update_V2.5_web/ >/dev/null 2>&1
if [ $? != 0 ]; then
echo "[ERROR:folder /home/work/update/update_V2.5_web/ not exist,please do [2.update file check] first!]"
return
fi
chown -R omcweb:omcweb /home/work/update/update_V2.5_web/
chmod 775 /home/work/update/update_V2.5_web/*
ls -l /home/work/update/update_V2.5_web/
echo " "
quantity=`find /home/work/update/update_V2.5_web -type f| wc -l`
size=`du -cb /home/work/update/update_V2.5_web/*|grep total|awk -F " " '{print$1}'`
echo "[tolal quantity:$quantity]"
echo "[total size:$size]"
echo "[owner change check OK? press 'y' or 'n' to continue]"
while true; do
read ca;
if [ -z $ca ];then
echo " ";
elif [ $ca == 'n' ];then
echo "[ERROR:program teminated,please change owner again]"
exit 0 ;
elif [ $ca == 'y' ];then
echo "[owner change check finished,you can do [ file update ] next!]";
break
else
echo "[please input 'y' or 'n'] ";
fi
done
}
function file_update()
{
cd $update_dir
if [ $? != 0 ];then
return
fi
echo "[Omcstop]"
su - das_uq -c omcstop
echo "[Omcstop check: press 'y' or 'n' to continue]"
read da;
if [ -z $da ];then
echo "[Please input 'y' or 'n']";
elif [ $da == 'n' ];then
echo "[ERROR: Program teminated, please omcstop by hand]"
exit 0;
elif [ $da == 'y' ];then
echo "[Omcstop successfully!]";
else
echo "[Please input 'y' or 'n']";
fi
echo "[Updating...]"
rm -rf /home/das_uq/bin/applserv
cp -rf $update_dir/applserv /home/das_uq/bin
if [ $? == 0 ];then
let m++
fi
rm -rf /home/das_uq/bin/gprsserv
cp -rf $update_dir/gprsserv /home/das_uq/bin
if [ $? == 0 ];then
let m++
fi
rm -rf /home/das_uq/bin/grrusend
cp -rf $update_dir/grrusend /home/das_uq/bin
if [ $? == 0 ];then
let m++
fi
rm -rf /home/das_uq/bin/grrurecv
cp -rf $update_dir/grrurecv /home/das_uq/bin
if [ $? == 0 ];then
let m++
fi
rm -rf /home/das_uq/bin/commserv
cp -rf $update_dir/commserv /home/das_uq/bin
if [ $? == 0 ];then
let m++
fi
#rm -rf /home/das_uq/bin/systemalarm
#cp -rf $update_dir/systemalarm /home/das_uq/bin
#if [ $? == 0 ];then
# let m++
#fi
rm -rf /home/das_uq/bin/timeserv
cp -rf $update_dir/timeserv /home/das_uq/bin
if [ $? == 0 ];then
let m++
fi
rm -rf /home/das_uq/lib/libomcpublic.so
cp -rf $update_dir/libomcpublic.so /home/das_uq/lib
if [ $? == 0 ];then
let m++
fi
rm -rf /home/das_uq/lib/libebdgdlmysql.so
cp -rf $update_dir/libebdgdlmysql.so /home/das_uq/lib
if [ $? == 0 ];then
let m++
fi
echo "[$m files copied!]"
echo "[Files update check...]"
chmod +x /home/das_uq/bin
chown -R das_uq:das_uq /home/das_uq/
ls -l /home/das_uq/bin/applserv
if [ $? == 0 ];then
let n++
fi
ls -l /home/das_uq/bin/gprsserv
if [ $? == 0 ];then
let n++
fi
ls -l /home/das_uq/bin/grrusend
if [ $? == 0 ];then
let n++
fi
ls -l /home/das_uq/bin/grrurecv
if [ $? == 0 ];then
let n++
fi
ls -l /home/das_uq/bin/commserv
if [ $? == 0 ];then
let n++
fi
#ls -l /home/das_uq/bin/systemalarm
#if [ $? == 0 ];then
# let n++
#fi
ls -l /home/das_uq/bin/timeserv
if [ $? == 0 ];then
let n++
fi
ls -l /home/das_uq/lib/libomcpublic.so
if [ $? == 0 ];then
let n++
fi
ls -l /home/das_uq/lib/libebdgdlmysql.so
if [ $? == 0 ];then
let n++
fi
echo "[$n files listed!]"
echo "[Files update check OK? (y or n)]"
while true; do
read db;
if [ -z $db ];then
echo "[Please input 'y' or 'n'] "
elif [ $db == 'n' ];then
echo "[ERROR: files update check failed, exit]"
exit 0;
elif [ $db == 'y' ];then
echo "[File update check finished]"
break;
else
echo "[Please input 'y' or 'n'] "
fi
done
echo "[Omcstart]"
su - das_uq -c omcstart
echo "[Is omcstart successful? (y or n)]"
while true
do
read dc;
if [ -z $dc ];then
echo "[Please input 'y' or 'n']";
elif [ $dc == 'n' ];then
echo "[ERROR: program teminated, please omcstart by hand!]"
exit 0;
elif [ $dc == 'y' ];then
echo "[Omcstart successfully!]";
break
else
echo "[Please input 'y' or 'n']";
fi
done
}
while true; do
echo " [UQ NMS V2.5 update_app script]"
echo " "
echo " 1.[file backup]"
echo " 2.[update file check]"
echo " 3.[owner change]"
echo " 4.[file update]"
echo " 5.[quit]"
echo " "
echo -n "Please choose the number: "
read selected
case $selected in
1)
echo "[***file backup*** confirm,please input 'y' or 'n' to continue]"
while true; do
read ab;
if [ -z $ab ];then
echo "[please input 'y' or 'n'] ";
elif [ $ab == 'n' ];then
echo "[*****Back to main menu******]"
break;
elif [ $ab == 'y' ];then
file_backup;
break;
else
echo "[please input 'y' or 'n'] ";
fi
done
;;
2)
echo "[***update file check*** confirm,please input 'y' or 'n' to continue]"
while true; do
read bc;
if [ -z $bc ];then
echo "[please input 'y' or 'n'] ";
elif [ $bc == 'n' ];then
echo "[*****Back to main menu******]"
break;
elif [ $bc == 'y' ];then
echo "[update file check]";
update_file_check;
break;
else
echo "[please input 'y' or 'n'] ";
fi
done
;;
3)
echo "[***owner change*** confirm,please input 'y' or 'n' to continue]"
while true; do
read cb;
if [ -z $cb ];then
echo "[please input 'y' or 'n'] ";
elif [ $cb == 'n' ];then
echo "[*****Back to main menu******]"
break;
elif [ $cb == 'y' ];then
echo "[owner change]";
owner_change;
break;
else
echo "[please input 'y' or 'n'] ";
fi
done
;;
4)
echo "[***File update*** confirm,please input 'y' or 'n' to continue]"
while true
do
read dd;
if [ -z $dd ];then
echo "[Please input 'y' or 'n'] ";
elif [ $dd == 'n' ];then
echo "[*****Back to main menu******]"
break;
elif [ $dd == 'y' ];then
echo "[File update]";
file_update;
break;
else
echo "[Please input 'y' or 'n'] ";
fi
done
;;
5)
echo " "
echo "[script quit,GoodBye!]"
exit 0;
;;
*)
echo "[Error input,please input 1-5!]"
esac
done