-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(metadata): script to update all metadata (#387)
* chore(metadata): script to update all metadata * feat(update metadata): use merge instead of copying piece by piece * fix(meta data update): do not remove workingdir
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# sync properties in layers config file with live meta data | ||
# Usage: ./scripts/update-metadata.sh <layerId (optional)> | ||
|
||
|
||
version=0.6.1 | ||
workingDir="./download" | ||
layersConfigFile="../data/layers-config.json" | ||
|
||
# take optional layer ID from command line argument | ||
layerID=$1 | ||
|
||
# check if layer ID is set | ||
if [ -z $layerID ] | ||
then | ||
keys=$(jq -r 'keys[]' $layersConfigFile) | ||
else | ||
keys=$layerID | ||
fi | ||
|
||
# for all key of the layer config | ||
for datasetId in ${keys} | ||
do | ||
echo $datasetId | ||
|
||
# download metadata file | ||
path=gs://esa-cfs-tiles/$version/$datasetId/metadata.json | ||
metadataFileName=$workingDir/$datasetId-metadata.json | ||
gsutil -q cp $path $metadataFileName | ||
|
||
# merge layer config into metdata file | ||
jq -s ".[0] * .[1].\"$datasetId\"" $metadataFileName $layersConfigFile | gsutil -q cp - $path | ||
|
||
# set cachhing headers foir remote file | ||
gsutil -q setmeta -r -h "cache-control: no-cache" $path | ||
|
||
# delete files | ||
rm $metadataFileName | ||
done |