diff --git a/support-services/docker-entrypoint.d/00-remove-es-watermark.sh b/support-services/docker-entrypoint.d/00-remove-es-watermark.sh index e8983d0145..c3e5464230 100755 --- a/support-services/docker-entrypoint.d/00-remove-es-watermark.sh +++ b/support-services/docker-entrypoint.d/00-remove-es-watermark.sh @@ -10,4 +10,5 @@ curl -s -X PUT "elasticsearch:9200/_cluster/settings" -H 'Content-Type: applicat } }' +echo "" echo "Removed disk space watermark in ElasticSearch." diff --git a/support-services/docker-entrypoint.d/10-index-records.sh b/support-services/docker-entrypoint.d/10-index-records.sh index 154cb07e0d..6547631efa 100755 --- a/support-services/docker-entrypoint.d/10-index-records.sh +++ b/support-services/docker-entrypoint.d/10-index-records.sh @@ -5,6 +5,8 @@ password=admin xsrf_token=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee host=geonetwork:8080 +echo "Logging in to GeoNetwork..." + # first login to get an authenticated admin session jsessionid=$( curl -s "http://$host/geonetwork/signin" \ @@ -14,6 +16,8 @@ jsessionid=$( -c - | grep JSESSIONID | awk '{ print $7 }' ) +echo "Triggering full records indexation in GeoNetwork..." + # then trigger an indexing result=$( curl -s "http://$host/geonetwork/srv/api/site/index" \ @@ -39,8 +43,25 @@ do -H "Cookie: JSESSIONID=$jsessionid; XSRF-TOKEN=$xsrf_token" \ -H "X-XSRF-TOKEN: $xsrf_token" ) - echo "Indexing? $indexing" + echo "Currently indexing: $indexing" sleep 1 done +# finally check that the index has records in it +recordsCount=0 +while [ "$recordsCount" = '0' ]; +do + response=$( + curl -s "http://$host/geonetwork/srv/api/search/records/_search" \ + -H 'Accept: application/json, text/plain, */*' \ + -H 'Content-Type: application/json;charset=UTF-8' \ + -H "Cookie: JSESSIONID=$jsessionid; XSRF-TOKEN=$xsrf_token" \ + -H "X-XSRF-TOKEN: $xsrf_token" \ + --data-raw '{"size":0}' + ) + recordsCount=$(echo $response | sed 's/.*"hits":{"total":{"value":\([0-9]\+\).*/\1/g') + echo "Records found: $recordsCount" + sleep 2 +done + echo "Indexing job in GeoNetwork successful."