Former-commit-id:a02aeb236c
[formerly9f19e3f712
] [formerly06a8b51d6d
[formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]] Former-commit-id:06a8b51d6d
Former-commit-id:3360eb6c5f
118 lines
No EOL
4.3 KiB
Bash
118 lines
No EOL
4.3 KiB
Bash
#!/bin/bash
|
|
if [ ${#AWIPS_HOME} = 0 ]
|
|
then
|
|
path_to_script=`readlink -f $0`
|
|
export AWIPS_HOME=$(dirname $(dirname $(dirname $(dirname $path_to_script))))
|
|
fi
|
|
|
|
# $1 = Primary Site name
|
|
# $2 = Failed Site Name
|
|
|
|
if [ $# -ne 2 ]
|
|
then
|
|
log_msg "Incorrect number of arguments\nCorrect usage: export_bksite_grids primary_wfo failed_wfo"
|
|
exit 1
|
|
fi
|
|
|
|
. ${AWIPS_HOME}/GFESuite/ServiceBackup/configuration/svcbu.env
|
|
|
|
PRIMARY_SITE=`echo ${1} | tr '[A-Z]' '[a-z]'`
|
|
PRIMARY_CAPS_SITE=`echo ${1} | tr [a-z] [A-Z]`
|
|
FAILED_SITE=`echo ${2} | tr '[A-Z]' '[a-z]'`
|
|
FAILED_CAPS_SITE=`echo ${2} | tr [a-z] [A-Z]`
|
|
|
|
# Create the log file
|
|
logdir=${IFPS_LOG}/`date +%Y%m%d`
|
|
logfil=svcbu_export_bksite_grids_`date +%H%M`
|
|
logfile=${logdir}/${logfil}
|
|
[ ! -d ${logdir} ] && (umask 000;mkdir ${logdir})
|
|
touch ${logdir}/${logfil}
|
|
exec 1>${logdir}/${logfil} 2>&1
|
|
|
|
# Check the status of the lock file to see if we are OK to proceed
|
|
if [ -f ${LOCK_DIR}/${FAILED_SITE}exportBksiteGridsCS ];
|
|
then
|
|
log_msg Cannot export grids for ${FAILED_CAPS_SITE}. Export grids process already in progress!
|
|
exit 1
|
|
fi
|
|
|
|
touch ${LOCK_DIR}/${FAILED_SITE}exportBksiteGridsCS
|
|
|
|
#
|
|
# If this is a non-wfo/non-rfc site, they may not have an edit area for clipping - handle it
|
|
#
|
|
if [ "$SVCBU_GRIDAREA" == "" ] ; then
|
|
SVCBU_MASK=""
|
|
else
|
|
SVCBU_MASK="-m $SVCBU_GRIDAREA"
|
|
fi
|
|
|
|
log_msg "Exporting $FAILED_CAPS_SITE grids to central server"
|
|
log_msg 0
|
|
|
|
#Starting ifpnetCDF to pack the grids
|
|
log_msg "Running ifpnetCDF..."
|
|
log_msg 25
|
|
log_msg "Running ifpnetCDF...(May take awhile)"
|
|
log_msg "${GFESUITE_BIN}/ifpnetCDF -o ${logdir}/${FAILED_SITE}Grd.netcdf -h $SVCBU_HOST -r $CDSPORT -d ${FAILED_CAPS_SITE}_GRID__Official_00000000_0000 -k -t -c ${SVCBU_MASK}"
|
|
${GFESUITE_BIN}/ifpnetCDF -o ${logdir}/${FAILED_SITE}Grd.netcdf -h $SVCBU_HOST -r $CDSPORT -d ${FAILED_CAPS_SITE}_GRID__Official_00000000_0000 -k -t -c ${SVCBU_MASK}
|
|
if [ $? -ne 0 ]; then
|
|
log_msg "ifpnetCDF process failed to create grids to send to the central server. Exiting..."
|
|
log_msg "ERROR: ifpnetCDF failed..."
|
|
rm -f ${LOCK_DIR}/${FAILED_SITE}exportBksiteGridsCS ${logdir}/${FAILED_SITE}Grd.netcdf*
|
|
exit 1
|
|
fi
|
|
# Store the site-id in siteID.txt file to get tarred.
|
|
echo $FAILED_SITE > ${logdir}/siteID.txt
|
|
|
|
# Switch to log directory to tarup the file.
|
|
cd $logdir
|
|
|
|
#tar the netcdf file again to preserve the file name so that when importing
|
|
#we can retrieve the site id from the file name
|
|
tar cvf ${FAILED_SITE}Grd.netcdf.tar ${FAILED_SITE}Grd.netcdf.gz siteID.txt
|
|
|
|
|
|
log_msg "Preparing package for msg_send..."
|
|
log_msg 60
|
|
#form the subject line for msg_send which uses it as the file name in the central server
|
|
#h_mach=`hostname|cut -d- -f2`
|
|
subj=${FAILED_SITE}Grd
|
|
log_msg "The subject line of msg_send is $subj"
|
|
#
|
|
#calling msg_send to send the data to the central server
|
|
log_msg "Sending the gridded data to the central server..."
|
|
log_msg 90
|
|
log_msg "Sending the gridded data to the central server..."
|
|
# We need to add another -c command in message handling system.
|
|
# Send the grids to the central server
|
|
# If we find a valid WMO Header, then add -i argument to msg_send call.
|
|
# Otherwise, don't add it.
|
|
if [ -n "${SVCBU_WMO_HEADER}" ]; then
|
|
msgSendOutput=$($MSG_SEND_COMMAND -e ${logdir}/${FAILED_SITE}Grd.netcdf.tar -a ${SVCBU_ADDRESSEE} -i ${SVCBU_WMO_HEADER} -s $subj -c 20)
|
|
exitValue=$?
|
|
if [ $exitValue -ne 0 ]
|
|
then
|
|
log_msg "msg_send has failed to send ${logdir}/${FAILED_SITE}Grd.netcdf.tar"
|
|
log_msg "msg_send FAILED with exit value $exitValue and the following error: $msgSendOutput"
|
|
rm -f ${LOCK_DIR}/${FAILED_SITE}exportBksiteGridsCS ${logdir}/${FAILED_SITE}Grd.netcdf*
|
|
exit 1
|
|
fi
|
|
else
|
|
msgSendOutput=$($MSG_SEND_COMMAND -e ${logdir}/${FAILED_SITE}Grd.netcdf.tar -a ${SVCBU_ADDRESSEE} -s $subj -c 20)
|
|
exitValue=$?
|
|
if [ $exitValue -ne 0 ]
|
|
then
|
|
log_msg "msg_send has failed to send ${logdir}/${FAILED_SITE}Grd.netcdf.tar"
|
|
log_msg "msg_send FAILED with exit value $exitValue and the following error: $msgSendOutput"
|
|
rm -f ${LOCK_DIR}/${FAILED_SITE}exportBksiteGridsCS ${logdir}/${FAILED_SITE}Grd.netcdf*
|
|
exit 1
|
|
fi
|
|
fi
|
|
log_msg Successfully sent message. MESSAGE ID: $msgSendOutput
|
|
log_msg 100
|
|
rm -f ${LOCK_DIR}/${FAILED_SITE}exportBksiteGridsCS
|
|
#delete the temporary netCDF file as well.
|
|
rm -f ${logdir}/${FAILED_SITE}Grd.netcdf.*
|
|
log_msg "All done. Export Gridded data has completed"
|
|
exit 0 |