#! /bin/bash
#
# push_cips_daily_daisy_to_pdc.sh
#
# Author: Lon Riesberg
#
# Purpose:
#   Pushes the most recent CIPS Daily Daisy to the Hampton
#   University ftp site.  This is set up specifically for 
#   access by NASA for shuttle missions and ISS coordination.    
#
# Notes:
#   Occassionally, a Level 3 file hasn't been created yet when 
#   this script runs as cron.  With reprocessing, the file 
#   eventually ends up being created (e.g. Monday a.m. after
#   a weekend crash.  To automate things as much as possible,
#   this script copies over the most recent 3 daily daisies.
#      
# Date
#   June 26, 2008
#

# as long as the remote file structure remains intact,
# only the next two lines need to be updated for new data versions
daisyVersion="v03.20"
pathToDaisy="/aim/data/cips/v3.20/north_2009/level_3/"

# create filenames for the filename to get and  
# its corresponding sending filename

# yesterday
year=`date '+%Y'`
today=`date '+%j'`
yesterday=$((today - 1))
localFile="cips_sci_3a_${year}-${yesterday}_${daisyVersion}_prelim.png"
remoteFile="daisy_pr_${year}${yesterday}_px.png"
destination_dir="ftp_shuttle/${year}-${yesterday}"
`scp -v ${pathToDaisy}${localFile} aim_cips@aim.hamptonu.edu:~/${destination_dir}/${remoteFile}`


# 2 days ago
two_days_ago=$((today - 2))
localFile="cips_sci_3a_${year}-${two_days_ago}_${daisyVersion}_prelim.png"
remoteFile="daisy_pr_${year}${two_days_ago}_px.png"
destination_dir="ftp_shuttle/${year}-${two_days_ago}"
`scp -v ${pathToDaisy}${localFile} aim_cips@aim.hamptonu.edu:~/${destination_dir}/${remoteFile}`


# 3 days ago
three_days_ago=$((today - 3))
localFile="cips_sci_3a_${year}-${three_days_ago}_${daisyVersion}_prelim.png"
remoteFile="daisy_pr_${year}${three_days_ago}_px.png"
destination_dir="ftp_shuttle/${year}-${three_days_ago}"
`scp -v ${pathToDaisy}${localFile} aim_cips@aim.hamptonu.edu:~/${destination_dir}/${remoteFile}`

exit 0
#Done
