Skip to content

Commit

Permalink
Script reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBlissett committed Feb 15, 2022
1 parent 235d24c commit 392cc83
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/resources/bin/crawl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ function download {
#Downloads latest sha1 checksum.
function downloadJarSha1 {
URL=`getArtifactUrl -s https://repository.gbif.org -g org.gbif.content -a content-crawler -v LATEST -r $1`
echo Download jar sha1 ${URL}.sha1
echo "Download JAR SHA1 ${URL}.sha1"
set -o pipefail
curl -Ss -L "${URL}.sha1" | sed -n 's/<sha1>\(.*\)<\/sha1>/\1/p' > latest.sha1
echo "${URL}.sha1 downloaded"
ls -l latest.sha1
}

#Download configuration settings from GitHub.
#Receives as parameter the environment/file name to be downloaded.
function downloadConfig {
echo "Get configuration from github"
echo "Get configuration from GitHub"
curl -Ss --fail -H "Authorization: token $1" -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/gbif/gbif-configuration/contents/content-crawler/$2.yml
echo "Configuration received"
}

function getArtifactUrl {
Expand Down Expand Up @@ -108,12 +112,14 @@ sed -i "s|_mendeleyAuthToken|$MENDELEY_AUTH_TOKEN|g" $P.yml
downloadJarSha1 $REPOSITORY
if [ -f jar.sha1 ] && [ -f content-crawler.jar ]; then
if ! cmp -s latest.sha1 jar.sha1; then
echo "Downloading updated JAR file"
download $REPOSITORY
else
echo "Using previously download jar file since content is the same"
echo "Using previously download JAR file since content is the same"
fi
else
download $REPOSITORY
echo "Downloading JAR file"
download $REPOSITORY
fi
rm -f latest.sha1
echo "Running crawler"
Expand Down

0 comments on commit 392cc83

Please sign in to comment.