#!/bin/bash # Script to mirror the JPSS ancillary data archive that contains # the files required to create the CSPP SDRs. At the point # of this writing, it includes the TLE and PolarWander files. # TLE files are available every day except weekends and American # holidays. PolarWander files are issued once per week. # # It is meant to by called by another script executed via cron # whick checks to see if it is already running, in case one gets stuck # and they start to back up. This script should be run at least once # per day. It uses 'lftp' to mirror the LUT ancillary data directory # from http://jpssdb.ssec.wisc.edu/cspp_v_2_0/ancillary , and will only # grab any new files that have been updated or changed since the last # update. # # Written by Kathleen Strabala UW/SSEC January 2013 # # # Before we do anything, check to see if lftp is installed on the # local machine which lftp > /dev/null if [ $? != 0 ] ; then echo " " > /dev/stderr echo "lftp not found locally. Please install and try again. " > /dev/stderr echo " " > /dev/stderr exit 1 fi echo "" echo "Begin CSPP SDR Ancillary File update on " `date` echo "" # See if local and remote ancillary directories have been set if [[ -z $CSPP_RT_ANC_CACHE_DIR ]]; then if [ -z "${CSPP_SDR_HOME}" ] ; then echo "Please set CSPP_SDR_HOME " exit 1 else echo "Will download data to: ${CSPP_SDR_HOME}/anc/cache." fi echo "The CSPP_RT_ANC_CACHE_DIR directory has not been set. Defaulting to $CSPP_SDR_HOME/anc/cache" export CSPP_RT_ANC_CACHE_DIR=${CSPP_SDR_HOME}/anc/cache fi if [[ -z $JPSS_REMOTE_ANC_DIR ]]; then export JPSS_REMOTE_ANC_DIR=http://jpssdb.ssec.wisc.edu/cspp_v_2_0/ancillary/ fi # Use lftp to download only the files that are new or updated date_range=(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) # Get todays date in the right format year=`date +%Y` month=`date +%m` dom=`date +%d` doy=`date +%j` jday=`expr $doy - 1` # Search date range for an acceptable file for delta in "${date_range[@]}" do jday1=`expr $jday - $delta` # Get todays date in the right format data_year=`date --date="$year-01-01 + $jday1 days" "+%Y"` data_month=`date --date="$year-01-01 + $jday1 days" "+%m"` data_dom=`date --date="$year-01-01 + $jday1 days" "+%d"` data_doy=`date --date="$year-01-01 + $jday1 days" "+%j"` # Get directory day_of_interest=${data_year}_${data_month}_${data_dom}_${data_doy} # lftp command FILE_TYPE="-I *.TLE* -I *.asc -I *PolarWander*" lftp -c "mirror --verbose --no-empty-dirs --only-newer --parallel=2 $JPSS_REMOTE_ANC_DIR/${day_of_interest} ${FILE_TYPE} ${CSPP_RT_ANC_CACHE_DIR}/" if [ $? -ne 0 ] ; then echo "CSPP Ancillary data update was not successful for day $day_of_interest ." echo "The remote directory may not exist yet for this day." echo "" fi done echo " " echo "CSPP SDR Ancillary data update completed." exit 0