-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync_elastic_search.sh
executable file
·109 lines (93 loc) · 2.89 KB
/
sync_elastic_search.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
#!/bin/bash
function create_tunnel() {
echo "Opening SSH tunnels"
ssh fa-gate-adm -fnNT -M -S datalab_socket -L 9202:datalab-host1:9202
ssh cloud-mi-elastic-search -fnNT -M -S cloud-es_socket -L 9201:localhost:9200
}
function close_tunnel() {
echo "Closing SSH tunnels"
ssh datalab_socket -S datalab_socket -O exit
ssh cloud-es_socket -S cloud-es_socket -O exit
}
function fail() {
echo "Something went wrong"
goodbye
exit 1
}
function interrupt() {
echo "Script interrupted by the user"
goodbye
exit 1
}
function goodbye() {
echo "Exiting"
close_tunnel
echo "Bye!"
}
function sync_acc() {
echo "Synchronizing accident analyzer"
curl -XDELETE 'localhost:9201/es5_prod_accidents'
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_accidents \
--output=http://localhost:9201/es5_prod_accidents \
--type=analyzer|| fail
echo "Synchronizing accident mapping"
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_accidents \
--output=http://localhost:9201/es5_prod_accidents \
--type=mapping || fail
echo "Synchronizing accident data"
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_accidents \
--output=http://localhost:9201/es5_prod_accidents || fail
echo "Synchronizing accident usagers"
curl -XDELETE 'localhost:9201/es5_prod_accidents_usagers'
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_accidents_usagers \
--output=http://localhost:9201/es5_prod_accidents_usagers || fail
echo "Synchronizing accident vehicles"
curl -XDELETE 'localhost:9201/es5_prod_accidents_vehicules'
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_accidents_vehicules \
--output=http://localhost:9202/es5_prod_accidents_vehicules || fail
}
function sync_pve() {
echo "Synchronizing PVE analyzer"
curl -XDELETE 'localhost:9201/es5_prod_pve'
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_pve \
--output=http://localhost:9201/es5_prod_pve \
--type=analyzer || fail
echo "Synchronizing PVE mapping"
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_pve \
--output=http://localhost:9201/es5_prod_pve \
--type=mapping || fail
echo "Synchronizing PVE data"
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_pve \
--output=http://localhost:9201/es5_prod_pve || fail
echo "Synchronizing Radars"
curl -XDELETE 'localhost:9201/es5_prod_equipements_radar'
./node_modules/.bin/elasticdump \
--quiet \
--input=http://localhost:9202/es5_prod_equipements_radar \
--output=http://localhost:9201/es5_prod_equipements_radar || fail
}
function main() {
trap interrupt 15
create_tunnel
sync_acc
sync_pve
goodbye
exit 0
}
main