From 6bb73084e4cdba0713f3b1bbbc01fdc8d33ddb94 Mon Sep 17 00:00:00 2001 From: Joost van Ulden Date: Thu, 3 Sep 2020 10:49:20 -0700 Subject: [PATCH] Added check to see if GitHub token is valid. --- python/add_data.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/python/add_data.sh b/python/add_data.sh index 6ec13b87..bc938608 100644 --- a/python/add_data.sh +++ b/python/add_data.sh @@ -7,6 +7,18 @@ POSTGRES_PASS=$2 POSTGRES_PORT=$3 DB_NAME=$4 +#get github token +GITHUB_TOKEN=`grep -o 'github_token = *.*' config.ini | cut -f2- -d=` + +status_code=$(curl --write-out %{http_code} --silent --output /dev/null -H "Authorization: token ${GITHUB_TOKEN}" \ + -O \ + -L https://api.github.com/repos/OpenDRR/openquake-models/contents/deterministic/outputs) + +if [[ "$status_code" -ne 200 ]] ; then + echo "GitHub token is not valid! Exiting!" + exit 0 +fi + # make sure PostGIS is ready to accept connections until pg_isready -h db-opendrr -p 5432 -U ${POSTGRES_USER} do @@ -14,9 +26,6 @@ do sleep 2; done -#get github token -GITHUB_TOKEN=`grep -o 'github_token = *.*' config.ini | cut -f2- -d=` - #get list of earthquake scenarios curl -H "Authorization: token ${GITHUB_TOKEN}" \ -O \