NOTE: Service Backup features are broken until DR 4300 lands on this branch. Change-Id: Ic0184c10c553187c8d0515f639c5a33fd3abde1f Former-commit-id: 732208b6600882a9ba9fcc0eefd7c8be0157beab
115 lines
No EOL
3.7 KiB
Bash
115 lines
No EOL
3.7 KiB
Bash
#!/bin/bash
|
|
|
|
##
|
|
# This software was developed and / or modified by Raytheon Company,
|
|
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
|
#
|
|
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
|
# This software product contains export-restricted data whose
|
|
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
|
# to non-U.S. persons whether in the United States or abroad requires
|
|
# an export license or other authorization.
|
|
#
|
|
# Contractor Name: Raytheon Company
|
|
# Contractor Address: 6825 Pine Street, Suite 340
|
|
# Mail Stop B8
|
|
# Omaha, NE 68106
|
|
# 402.291.0100
|
|
#
|
|
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
|
# further licensing information.
|
|
##
|
|
##############################################################################
|
|
# Process Received Digital Grids
|
|
# This is run at the backup site to merge the failed site's grids into the
|
|
# Fcst database.
|
|
#
|
|
# SOFTWARE HISTORY
|
|
#
|
|
# Date Ticket# Engineer Description
|
|
# ------------ ---------- ----------- --------------------------
|
|
# 06/16/14 3276 randerso Added -T to iscMosaic call
|
|
# 02/12/15 4103 dgilling Consolidated process_grids and
|
|
# proc_receive_grids into 1 script.
|
|
#
|
|
##############################################################################
|
|
|
|
|
|
if [ ${#AWIPS_HOME} = 0 ]
|
|
then
|
|
path_to_script=`readlink -f $0`
|
|
export AWIPS_HOME=$(dirname $(dirname $(dirname $(dirname $path_to_script))))
|
|
fi
|
|
|
|
. ${AWIPS_HOME}/GFESuite/ServiceBackup/configuration/svcbu.env
|
|
source ${AWIPS_HOME}/GFESuite/ServiceBackup/scripts/serviceBackupUtil.sh
|
|
|
|
# $1 = Path to packaged netcdf file received from MHS
|
|
# $2 = site ID for the file
|
|
import_file=${1}
|
|
SITE_ID=`echo ${2} | tr '[A-Z]' '[a-z]'`
|
|
|
|
# Create the log file
|
|
configureLogging "svcbu_receive_grids" ${SITE_ID}
|
|
|
|
# Check the status of the lock file to see if we are OK to proceed
|
|
lock_file=$(getLockFile "importGrids" ${SITE_ID})
|
|
lock_status=$(isOperationInProgress "importGrids" ${SITE_ID})
|
|
if [[ "${lock_status}" = "false" ]]
|
|
then
|
|
echo "Lock file not present for importing grids! Cannot continue!"
|
|
echo "FAILED" > ${lock_file}
|
|
exit 1
|
|
fi
|
|
|
|
echo "Processing file: $import_file"
|
|
FILESIZE=$(stat -c%s "$import_file")
|
|
echo "File Size is: $FILESIZE bytes."
|
|
|
|
#
|
|
# Retrieve the file from the MHS x400 directory
|
|
#
|
|
echo "Retrieving the file from the MHS x400 directory..."
|
|
OUTPUT_DIR=$(getTempDirectory "receive_grids" ${SITE_ID})
|
|
mv ${import_file} ${OUTPUT_DIR}/${SITE_ID}Grd.tar
|
|
cd ${OUTPUT_DIR}
|
|
#
|
|
# Update owner and permissions from root to ifps
|
|
#
|
|
chmod 777 ${OUTPUT_DIR}/${SITE_ID}Grd.tar
|
|
|
|
echo "File copied. Continuing grid processing..."
|
|
|
|
echo "Unzipping/untarring netcdf file..."
|
|
sleep 2
|
|
|
|
tar -xOf ${SITE_ID}Grd.tar > ${SITE_ID}Grd.netcdf.gz --exclude siteID.txt
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "ERROR: tar failed to untar ${SITE_ID}Grd.tar."
|
|
echo "FAILED" > ${lock_file}
|
|
exit 1
|
|
fi
|
|
rm -f ${SITE_ID}Grd.tar
|
|
|
|
# use iscMosaic to load grids into databases
|
|
echo "Running iscMosaic to unpack gridded data..."
|
|
SITE_ID_CAPS=`echo ${SITE_ID} | tr '[a-z]' '[A-Z]'`
|
|
echo "SVCBU_HOST is $SVCBU_HOST"
|
|
echo "CDSPORT is $CDSPORT"
|
|
|
|
echo "Beginning iscMosaic"
|
|
${GFESUITE_BIN}/iscMosaic -h $SVCBU_HOST -r $CDSPORT -d ${SITE_ID_CAPS}_GRID__Fcst_00000000_0000 -f ${OUTPUT_DIR}/${SITE_ID}Grd.netcdf.gz -n -T
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "ERROR: iscMosaic failed to import grids from ${SITE_ID_CAPS}_GRID__Fcst_00000000_0000"
|
|
echo "FAILED" > ${lock_file}
|
|
exit 1
|
|
fi
|
|
|
|
echo "Cleaning up netcdf file"
|
|
rm -f ${SITE_ID}Grd*
|
|
echo "SUCCESS" > ${lock_file}
|
|
echo "Digital Data Import Complete!"
|
|
|
|
exit 0 |