From a0f4fbb797c507b1e5a121e4fc04c5c2cda7b059 Mon Sep 17 00:00:00 2001 From: Rob Kooper Date: Mon, 29 Jan 2018 17:30:31 -0600 Subject: [PATCH 1/2] thredds script --- scripts/thredds/README.md | 3 ++ scripts/thredds/thredds.sh | 88 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 scripts/thredds/README.md create mode 100644 scripts/thredds/thredds.sh diff --git a/scripts/thredds/README.md b/scripts/thredds/README.md new file mode 100644 index 00000000..8193fe82 --- /dev/null +++ b/scripts/thredds/README.md @@ -0,0 +1,3 @@ +The script in this folder will create a catalog.xml output that can be +used by the thredds server. This script is run every day and will update +the thredds server to show the latest data available. diff --git a/scripts/thredds/thredds.sh b/scripts/thredds/thredds.sh new file mode 100644 index 00000000..41795a38 --- /dev/null +++ b/scripts/thredds/thredds.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +dataset() { + FOLDER="$1" + DSPATH="$2" + TITLE="$3" + + echo " " + + IFS=$'\n' + LAST_DATE="" + LAST_TIME="" + + FILES=$( find ${FOLDER} -name \*.nc | sort ) + #FILES=$( cat ncfiles.txt | sort ) + for X in ${FILES}; do + # remove leading whitespace, and extract information + X="${X#${FOLDER}}" + X="${X//[[:space:]]/}" + X="${X:1}" + echo "$X" + + DATE=$( echo "$X" | cut -d "/" -f1 ) + if [ "$DATE" != "$LAST_DATE" ]; then + if [ "$LAST_DATE" != "" ]; then + echo ' ' + echo ' ' + fi + LAST_TIME="" + LAST_DATE="$DATE" + echo " " + fi + + TIME=$( echo "$X" | cut -d "/" -f2) + if [ "$TIME" != "$LAST_TIME" ]; then + if [ "$LAST_TIME" != "" ]; then + echo ' ' + fi + LAST_TIME="$TIME" + NAME=$( echo "$TIME" | cut -d "_" -f3 | tr "-" ":" | cut -d ":" -f 1,2 ) + echo " " + fi + + NAME=$( echo "$X" | cut -d "/" -f3 ) + echo " " + echo ' ' + done + echo ' ' + echo ' ' + echo ' ' +} + +# ---------------------------------------------------------------------- +# HEADER +# ---------------------------------------------------------------------- +cat << EOF + + + + + + + + + + + + + + + +EOF + +# ---------------------------------------------------------------------- +# DATASETS +# ---------------------------------------------------------------------- +dataset "/home/sites/ua-mac/Level_1/vnir_netcdf" "uamac_hs" "UAMac Hyperspectral" + +# ---------------------------------------------------------------------- +# FOOTER +# ---------------------------------------------------------------------- +echo ' ' +echo '' From 05318ae31d3a9020d563870df25721c8d0cb072e Mon Sep 17 00:00:00 2001 From: Rob Kooper Date: Mon, 29 Jan 2018 22:38:38 -0600 Subject: [PATCH 2/2] update readme --- scripts/thredds/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/thredds/README.md b/scripts/thredds/README.md index 8193fe82..6da1a1c8 100644 --- a/scripts/thredds/README.md +++ b/scripts/thredds/README.md @@ -1,3 +1,19 @@ The script in this folder will create a catalog.xml output that can be used by the thredds server. This script is run every day and will update the thredds server to show the latest data available. + +The script writes the catalog.xml to a folder that is similair to the +example 4.6.8 thredds server. + +This script is used with cronjob and the following little script: + +``` +#!/bin/bash + +cd /home/ubuntu +./thredds.sh > thredds/catalog.xml +/usr/sbin/service tomcat8 restart +``` + +The output of the script can be found at: +https://terraref.ncsa.illinois.edu/thredds/