-
Notifications
You must be signed in to change notification settings - Fork 5
/
checkCompactedProperties.sh
37 lines (31 loc) · 1.11 KB
/
checkCompactedProperties.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
#!/bin/bash
# See #171.
# Shall be started after indexing of an update or a fulldump.
# Checks if there are uncompacted field. If so, mail an alert.
# After uncompacted fields are fixed, build new index to update data and mapping.
# First parameter is the name of the index that will be checked. Without
# parameter, the _newest_ gnd-prefixed index is determined and checked - this
# can be used after indexing a fulldump.
set -euo pipefail # See http://redsymbol.net/articles/unofficial-bash-strict-mode/
IFS=$'\n\t'
ES="weywot5.hbz-nrw.de:9200"
INDEX=""
if [ -n "${1-}" ]; then
INDEX=$1
fi
SEARCH=http
RECIPIENT=lobid-admin
if [ -z ${INDEX-} ]; then
INDEX=$(curl $ES/_settings |jq .[].settings.index.provided_name |grep gnd | tr -d \" | sort |tail -n1)
fi
echo "check index-name: $INDEX"
MESSAGE=$(curl $ES/$INDEX/_mapping | jq -r 'paths | map(.|tostring)|join(".")' |grep $SEARCH.*type$ || exit 0)
if [ -z "${MESSAGE-}" ]; then
echo "no uncompacted fields found"
exit 0
fi
echo "there are uncompacted fields: $MESSAGE"
mail -s "Alert GND: found not compacted field(s)!" "$RECIPIENT@hbz-nrw.de" << EOF
$MESSAGE
EOF
exit 1