#! /bin/bash #+ # NAME: # sync_ips_mirror # PURPOSE: # CALLING SEQUENCE: # sync_daily_mirror [$1 $2] # OPTIONAL INPUTS: # $1 list of email addresses # $2 if equal to '-mirror' then the the data from Nagoya are # mirrored even if there is no email alert. # OUTPUTS: # $? return status # 0: run tomography # 1: no need to run tomography, because # no new email arrived, or # no new daily files downloaded, or # email confirmation failed, or # merging of daily file with yearly files failed # File $TUB/daily_ips.txt stores output from the sorting program 'dailyips'. # CALLS: # sync_ips_email, mirror, daily_ips, run_glevel # RESTRICTIONS: # Needs the Perl script 'mirror'. Currently the version included # with SolarSoft is used. # SIDE EFFECTS: # The content of all new daily IPS files are emailed to everyone # on the $1 list of email addresses. # PROCEDURE: # First the script sync_ips_email is called to check whether a new email # has arrived from Nagoya indicating the availability of new IPS data. # If no new email has arrived, return status=1. # # If a new email has arrived, then the new IPS data are downloaded from # stesun5.stelab.nagoya-u.ac.jp, and are stored in $NAGOYA/ipsrt # If no new data files ar downloaded, return status=1. # # Then the program $EXE/dailyips is called to add the new data to the # yearly data files (stored in $NAGOYA/daily). # If this integration fails, return status=1 # # Then the idl program run_glevel.pro is run to calculate # g-level values. These are added to the yearly files. # MODIFICATION HISTORY: # OCT-2002, Paul Hick (UCSD/CASS) # Split off from sync_daily_ips # OCT-2003, Paul Hick (UCSD/CASS; pphick@ucsd.ed) # Replaced bash script sync_ips_email by Python script # with same name #- # People on the honcho list receive emails. honcho=$1 # === Initialization section ================= # IPS daily files have names VLIST_UCSD_timemarker # Directory where yearly IPS files are located (NOT the same as $local_dir) # Scratch file for storing file names for downloaded daily IPS files # File connected to standard ouput for daily_ips daily_ips=VLIST_UCSD_ yearly_ips=$NAGOYA/daily vlist_got=$TUB/$daily_ips.got vlist_tmp=$TUB/$daily_ips.tmp #output=$TUB/cron_dailyips.txt rm_vlist_got="rm -f $vlist_got" if [ "$2" != "-mirror" ]; then sync_ips_email.py if [ $? = 0 ]; then echo $(date), no new mail: no download required exit 1 fi fi # Run the mirror program. # Check for lines starting with "Got VLIST_UCSD_". # Extract the file name and put in file $vlist_got after prefixing # the name of the local destination directory. local_dir=$NAGOYA/ipsrt/ remote_site=stesun5.stelab.nagoya-u.ac.jp remote_dir=/pub/ipsrt/ mirror.py job=nagoya_ipsrt local_dir=$local_dir remote_site=$remote_site remote_dir=$remote_dir recursive="false" > $vlist_tmp cat $vlist_tmp | grep "Got $daily_ips" | gawk --assign=here=$local_dir '{print here$2}' > $vlist_got rm -f $vlist_tmp # If $vlist_got is empty, then no new files were downloaded. # Otherwise it contains the names of files that were succesfully downloaded. if [ ! -s $vlist_got ]; then $rm_vlist_got echo $(date), no new files downloaded. exit 1 fi # We now know that new IPS data have been downloaded. echo $(date), new data downloaded. cat $vlist_got # At this point we know that new VLIST_UCSD files have been downloaded. if [ -n "$honcho" ]; then # Create backup directory $yearly_ips/(current year) if necessary daily_bu=$yearly_ips/$(date +%Y) if [ ! -d $daily_bu ]; then mkdir $daily_bu fi # Email the files to the honcho list. # Copy to backup directory $yearly_ips/(current year) cat $vlist_got | while read line; do new_file=$(echo $line | gawk '{n=split($0,a,"/"); print a[n]}') mail $honcho -s$new_file < $line cp -pv $line $daily_bu done fi # === Update IPS data files ================= # (integrate into yearly files; recalculate g-levels) # Run the sorting program to update the yearly files. # If the exit status of dailyips is not = 1 then the sorting went wrong, # or no data have been added to the yearly files. # Note that this is not necessary an error. Occasionally a daily file arrives # that is emptry (except for a header record). 'dailyips' would in that case # return exit status=3 (real errors have exit status 0,2 or 4). echo echo $(date), dailyips: adding new data to yearly files dailyips -year=$yearly_ips $vlist_got #> $output status=$? $rm_vlist_got if [ $status != 1 ]; then case $status in 3) echo "$(date), the new $daily_ips files do not contain new data" ;; *) echo "$(date), error integrating the new $daily_ips files into yearly files" ;; esac exit 1 fi echo echo $(date), run_glevel: updating g-level values echo "nagoya_glevel, /output, /use_min_glevel & exit" | idl -quiet exit 0