#!/bin/bash
source ~/.bash_profile

today=$(date "+%Y%m%d")
YYYYMM=$(date "+%Y-%m")
yesterday=$(date +"%Y%m%d" -d +"-1day")

rm -r /massdata2/weather/projects_lerc/MYJF_Data/$yesterday/1005/

cd /massdata2/weather/projects_lerc/MYJF_Data/$today/

if [[ -d "1005/" && -d "1006/" && -d "1007/" ]];then
    java -jar /massdata2/weather/projects_lerc/MYJF_Data/file-upload-1.1.3.jar /massdata2/weather/projects_lerc/MYJF_Data/$today/

    if [ -f "/massdata2/weather/projects_lerc/MYJF_Data/$today/log/$YYYYMM/done.txt" ];then 
        cp /massdata2/weather/projects_lerc/MYJF_Data/$today/log/$YYYYMM/done.txt /massdata2/weather/projects_lerc/MYJF_Data/$today/
        
        java -jar /massdata2/weather/projects_lerc/MYJF_Data/file-upload-1.1.3.jar /massdata2/weather/projects_lerc/MYJF_Data/$today/

    fi
fi
