Blame view

CEPTD/docker/logstash/dist/update.sh 1.15 KB
0d8c0f816   Thanasis Naskos   initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #!/bin/bash
  
  # Let's ensure normal operation on exit or if interrupted ...
  function fuCLEANUP {
    exit 0
  }
  trap fuCLEANUP EXIT
  
  # Check internet availability 
  function fuCHECKINET () {
  mySITES=$1
  error=0
  for i in $mySITES;
    do
      curl --connect-timeout 5 -Is $i 2>&1 > /dev/null
        if [ $? -ne 0 ];
          then
            let error+=1
        fi;
    done;
    echo $error
  }
  
  # Check for connectivity and download latest translation maps
0d86ee79d   Chris Bellas   Updated DTAG tran...
25
  myCHECK=$(fuCHECKINET "listbot.sicherheitstacho.eu")
0d8c0f816   Thanasis Naskos   initial commit
26
27
28
29
  if [ "$myCHECK" == "0" ];
    then
      echo "Connection to Netlify looks good, now downloading latest translation maps."
      cd /etc/listbot 
0d86ee79d   Chris Bellas   Updated DTAG tran...
30
31
      aria2c -s16 -x 16 https://listbot.sicherheitstacho.eu/cve.yaml.bz2 && \
      aria2c -s16 -x 16 https://listbot.sicherheitstacho.eu/iprep.yaml.bz2 && \
0d8c0f816   Thanasis Naskos   initial commit
32
33
34
35
36
37
38
39
40
41
42
43
44
      bunzip2 -f *.bz2
      cd /
    else
      echo "Cannot reach Github, starting Logstash without latest translation maps."
  fi
  
  # Make sure logstash can put latest logstash template by deleting the old one first
  echo "Removing logstash template."
  curl -XDELETE http://elasticsearch:9200/_template/logstash
  echo
  echo "Checking if empty."
  curl -XGET http://elasticsearch:9200/_template/logstash
  echo