2020-04-22 12:22:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# fail if any command fails
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [[ -z "${API_KEY}" ]]; then
|
|
|
|
echo "API_KEY not defined, should be api key to CJVT's gitea"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
OUT_FILE=conversions.csv
|
2020-07-01 21:16:02 +00:00
|
|
|
TEMP_FILE=$(mktemp)
|
2020-04-22 12:22:02 +00:00
|
|
|
|
2020-07-01 21:16:02 +00:00
|
|
|
rm -r $OUT_FILE
|
2020-04-22 12:22:02 +00:00
|
|
|
|
2020-07-01 21:16:02 +00:00
|
|
|
curl -s "https://gitea.cjvt.si/api/v1/repos/generic/data_admin/contents/resources/structure_conversions.csv?token=$API_KEY" -o $TEMP_FILE
|
|
|
|
echo "wc: $(wc $TEMP_FILE)"
|
|
|
|
cat $TEMP_FILE | python3 -c "import sys, json; print(json.load(sys.stdin)['content'])" | base64 -d > $OUT_FILE
|
2020-04-22 12:22:02 +00:00
|
|
|
|
2020-07-01 21:16:02 +00:00
|
|
|
rm -rf $TEMP_FILE
|