Skip to content

Commit

Permalink
Updates to the ERDDAP utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcullis committed Apr 27, 2022
1 parent 5ed8ff2 commit 809f8b8
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions erddap_utils.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
export ERDDAP_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
export ERDDAP_DATASETS_XML=${ERDDAP_DIR}/erddap/content/datasets.xml
export ERDDAP_DATA_DIR=${ERDDAP_DIR}/datasets
export ERDDAP_GENDATA_DIR=${ERDDAP_DIR}/gen_datasets
export ERDDAP_GENDATA_DIR=${ERDDAP_DIR}/generate_datasets
if [ -z $ERDDAP_URL ]; then
export ERDDAP_URL=cioosatlantic.ca
export ERDDAP_URL=http://127.0.0.1:8080/erddap
fi

erddap_vars() {
echo "ERDDAP_DIR: $ERDDAP_DIR"
echo "ERDDAP_DATASETS_XML: $ERDDAP_DATASETS_XML"
echo "ERDDAP_DATA_DIR: $ERDDAP_DATA_DIR"
echo "ERDDAP_GENDATA_DIR: $ERDDAP_GENDATA_DIR"
echo "ERDDAP_URL: $ERDDAP_URL"
}

erddap_generate_datasets_xml() {
pushd $ERDDAP_DIR
sudo bash GenerateDatasetsXml.sh
popd
}

erddap_copy_gendata() {
erddap_gendata_mv() {
# Move the latest output from GenerateDatasetXml.sh to $ERDDAP_GENDATA_DIR
dataset_id=$1
if [ -z $dataset_id ]; then
echo "Usage: erddap_copy_gendata <dataset id>"
Expand All @@ -25,6 +33,19 @@ erddap_copy_gendata() {
fi
}

erddap_gendata_cat() {
# Concatenate all generated XML files together to create datasets.xml
mv $ERDDAP_DATASETS_XML $ERDDAP_DATASETS_XML.bak
cat > $ERDDAP_DATASETS_XML << EOF
<?xml version="1.0" encoding="UTF-8" ?>
<erddapDatasets>
<requestBlacklist />
EOF
for xml_file in $ERDDAP_GENDATA_DIR/*.xml; do
cat $xml_file >> $ERDDAP_DATASETS_XML
done
}

erddap_dir() {
cd $ERDDAP_DIR
}
Expand All @@ -37,12 +58,12 @@ erddap_chown_content() {
sudo chown -R $USER ${ERDDAP_DIR}/erddap/content
}

erddap_index_html() {
curl "$ERDDAP_URL/index.html"
}

erddap_dataset_ids() {
if [ ! -z $ERDDAP_APACHE_PASS ]; then
curl https://$ERDDAP_URL/erddap/tabledap/allDatasets.tsv?datasetID
else
curl https://$ERDDAP_URL/erddap/tabledap/allDatasets.tsv?datasetID
fi
curl $ERDDAP_URL/tabledap/allDatasets.tsv?datasetID
}

erddap_refresh_dataset() {
Expand Down

0 comments on commit 809f8b8

Please sign in to comment.