diff --git a/scripts/thredds/README.md b/scripts/thredds/README.md new file mode 100644 index 00000000..6da1a1c8 --- /dev/null +++ b/scripts/thredds/README.md @@ -0,0 +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/ 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 ''