tx2_update_full_speed.sh
1.64 KB
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
#!/bin/bash
ori_dir=$(cd $(dirname $0);pwd)
cd $ori_dir
if [[ -p fifo_tmp ]]
then
rm fifo_tmp
fi
list_name=$1
file=$2
thread_num=11
mkfifo fifo_tmp
exec 9<>fifo_tmp
for i in `seq 1 $thread_num`
do
echo -ne "\n">&9
done
echo -e "\033[41;33mClean up residual of ansible tools, syslog and VAServer!\033[0m"
ansible $list_name -b -m raw -a "if [ -d /home/ubuntu/.ansible/tmp ];then rm -r /home/ubuntu/.ansible/tmp;fi;if [ -d /root/.ansible/tmp ];then rm -r /root/.ansible/tmp;fi;size=\$(du -sm /var/log|awk '{print \$1}');if [ \$size -gt 1000 ];then echo clean syslog;cat /dev/null > /var/log/syslog;cat /dev/null > /var/log/syslog.1;fi;cd /root/UserApp/services/analysis_service;if [ -d VAServer ];then rm -r VAServer;fi;pkill -9 VAServer;cat /dev/null"
echo -e "\033[41;33mCopy the analyzer to the child node!\033[0m"
hosts=`ansible $list_name --list-hosts|egrep -o [0-9]+.[0-9]+.[0-9]+.[0-9]+`
if [[ ! $hosts ]]
then
echo Please check /etc/ansible/hosts!
exit 0
fi
chmod 666 $file
time1=`date +%s`
IFS=$' '
while read host
do
read -u 9
{
sshpass -p ubuntu scp -o StrictHostKeyChecking=no $file ubuntu@$host:/home/ubuntu
printf "%-20s : %-8s\n-----------------\n\n" "==> $host" "DONE!"
echo -ne "\n">&9
} &
done <<< $hosts
wait
time2=`date +%s`
let cov=$time2-$time1
exec 9<&-;exec 9>&-
rm fifo_tmp
time2=`date +%s`
let use=time2-time1
echo Time-consuming: $use's'
echo -e "\033[41;33mUnzip the analyzer and clean the cache!\033[0m"
ansible $list_name -b -m raw -a "cd /home/ubuntu/;tar -zxf $file -C /root/UserApp/services/analysis_service/;rm $file;cat /root/UserApp/services/analysis_service/VAServer/last_version"