update_fx_config.sh
3.46 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
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
#!/bin/bash
if [[ $# == 2 ]]
then
type=slave
slave_int_ip=$1
master_int_ip=$2
elif [[ $# == 3 ]]
then
type=master
master_ext_ip=$1
master_int_ip=$2
plat_ip=$3
else
echo Update Config ERROR!
exit 0
fi
master_int_short=`egrep -o [0-9]+.[0-9]+$ <<< $master_int_ip`
update_slave(){
slave_type='slave-'$master_int_short
if [[ `cat /proc/net/dev|egrep -o eth1` && `grep ^if /root/UserApp/Daemon/start.sh|grep eth1` ]]
then
#sed -i '/.\/OpsDaemon/a \\n=====' /root/UserApp/Daemon/start.sh
#sed -i '/^else/a \\n=====' /root/UserApp/Daemon/start.sh
#sed -i '/=====/,/=====/s/^/#/' /root/UserApp/Daemon/start.sh
#sed -i '/^fi/,$s/^/#/' /root/UserApp/Daemon/start.sh
mv /root/UserApp/Daemon/start.sh /root/UserApp/Daemon/start.sh.bk
echo -e '#!/bin/bash\n\ncd /root/UserApp/Daemon\nchmod +x OpsDaemon.sh\n./OpsDaemon.sh &\n\ncd /root/UserApp/Daemon\nchmod +x AnalysisDaemon.sh\n./AnalysisDaemon.sh &' > /root/UserApp/Daemon/start.sh
chmod +x /root/UserApp/Daemon/start.sh
cp /root/UserApp/vioncfg/Ops/ServerConfig_slave.xml /root/UserApp/vioncfg/Ops/ServerConfig.xml
pkill -9 mediaSvr
pkill -9 MediaServer
pkill -9 dataExport
pkill -9 DataExport
pkill -9 OpeateServer
pkill -9 Nginx
/root/UserApp/Daemon/AnalysisDaemon.sh
fi
sed -i "1s/[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/$slave_int_ip/" /root/UserApp/vioncfg/VAServer_System.xml
sed -i "2,\$s/<IP>[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/<IP>$master_int_ip/" /root/UserApp/vioncfg/VAServer_System.xml
sed -i "s/>2</>10</2" /root/UserApp/vioncfg/VAServer_System.xml
sed -i "1,/>8851</s/[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/$master_int_ip/" /root/UserApp/vioncfg/Ops/ServerConfig.xml
sed -i "s/deviceType1/$slave_type/" /root/UserApp/vioncfg/Ops/ServerConfig.xml
sed -i "/<NTP/,/<NTP/s/[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+<\/NTP/$master_int_ip<\/NTP/" /root/UserApp/vioncfg/Ops/ServerConfig.xml
pkill -9 VAServer
pkill -9 OpeateServer
}
update_master(){
master_type='master-'$master_int_short
sed -i "1,/>8851</s/[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/$plat_ip/" /root/UserApp/vioncfg/Ops/ServerConfig.xml
sed -i "/<DNS/,/<\/DNS/s/IP>[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/IP>$master_ext_ip/1" /root/UserApp/vioncfg/Ops/ServerConfig.xml
sed -i "/<DNS/,/<\/DNS/s/IP>[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/IP>$master_int_ip/2" /root/UserApp/vioncfg/Ops/ServerConfig.xml
sed -i "/<NTP/,\$s/[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+<\/NTP/$plat_ip<\/NTP/" /root/UserApp/vioncfg/Ops/ServerConfig.xml
sed -i "s/deviceType1/$master_type/" /root/UserApp/vioncfg/Ops/ServerConfig.xml
sed -i "/<ip>/,/<port>/s/[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/$master_int_ip/" /root/UserApp/vioncfg/DataExportService/DataExportConfig.xml
sed -i "s/<configServIp>[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/<configServIp>$plat_ip/" /root/UserApp/vioncfg/DataExportService/DataExportConfig.xml
sed -i "s/<LocalIp>[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/<LocalIp>$master_ext_ip/" /root/UserApp/vioncfg/MediaServer/mediaServer.xml
sed -i "s/<ServerIp>[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/<ServerIp>$plat_ip/" /root/UserApp/vioncfg/MediaServer/mediaServer.xml
if [[ -f /etc/haproxy/haproxy.cfg_ ]]
then
sed -i "/videoupload/,/server/s/ [0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/ $plat_ip/" /etc/haproxy/haproxy.cfg
service haproxy restart
fi
pkill -9 OperateServer
pkill -9 DataExport
pkill -9 MediaServer
}
if [[ $type == slave ]]
then
update_slave
echo "子节点($slave_int_ip)配置更新完成!"
elif [[ $type == master ]]
then
update_master
echo "主节点($master_int_ip)配置更新完成!"
fi