Check if urls is null before committing

This commit is contained in:
Thomas Stokes committed 2023-12-19 16:22:11 +01:00
1 parent f7927009b3
commit dfd178b5f3
1 file changed
+8 -2
@@ -1,7 +1,13 @@
#!/bin/bash
GIT_ROOT=/home/wiki/gitwiki
mongo --quiet "mongodb://dbserver.internal.sapsailing.com:10201/winddb?replicaSet=archive" --eval 'db.TRACTRAC_CONFIGURATIONS.find({}, {TT_CONFIG_JSON_URL : 1}).toArray()' | grep -v ObjectId | jq -r '.[].TT_CONFIG_JSON_URL' | sort -u >"${GIT_ROOT}/configuration/tractrac-json-urls"
PATH_TO_TRAC_TRAC_URLS="configuration/tractrac-json-urls"
urls=$(mongo --quiet "mongodb://dbserver.internal.sapsailing.com:10201/winddb?replicaSet=archive" --eval 'db.TRACTRAC_CONFIGURATIONS.find({}, {TT_CONFIG_JSON_URL : 1}).toArray()' | grep -v ObjectId | jq -r '.[].TT_CONFIG_JSON_URL' )
if [[ $urls == "null" ]]; then
exit 1
else
echo ${urls} | sort -u >"${GIT_ROOT}/${PATH_TO_TRAC_TRAC_URLS}"
fi
cd "${GIT_ROOT}"
git add "${GIT_ROOT}/configuration/tractrac-json-urls"
git add "${GIT_ROOT}/${PATH_TO_TRAC_TRAC_URLS}"
git commit -m "Updated tractrac-json-urls"
git push