Files
sailing-analytics/configuration/update-tractrac-urls-to-archive.sh
T
Thomas Stokes e7434560b3 b5938: backwards-compatibility update-trac-trac..
Use the number of args to ensure old editions still succeed.
Only commit in the "else" branch (same file)
2024-01-11 10:38:05 +01:00

19 lines
743 B
Bash
Executable File

#!/bin/bash
if [[ $# -eq 0 ]]; then
GIT_ROOT=/home/wiki/gitwiki
else
GIT_ROOT=$1
fi
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
echo "Mongo db returns null for tractrac url discovery" | notify-operators "MongoDB/tractrac urls issue"
exit 1
else
echo ${urls} | sort -u >"${GIT_ROOT}/${PATH_TO_TRAC_TRAC_URLS}"
cd "${GIT_ROOT}"
git add "${GIT_ROOT}/${PATH_TO_TRAC_TRAC_URLS}"
git commit -m "Updated tractrac-json-urls"
git push
fi