#!/bin/sh
#################################################################
#                                                               #
#       Copyright 2010 Fidelity Information Services, Inc       #
#                                                               #
#       This source code contains the intellectual property     #
#       of its copyright holder(s), and is made available       #
#       under a license.  If you do not know the terms of       #
#       the license, please stop and do not read further.       #
#                                                               #
#################################################################
if [ ! -f "/usr/local/gtm"/gtmprofile ] ; then echo Cannot find file "/usr/local/gtm"/gtmprofile to source
else
    . "/usr/local/gtm"/gtmprofile
    timestamp=`date -u +%Y%m%d%H%M%S`"UTC"
    ( cd `dirname $gtmgbldir` ; \
	$gtm_dist/mupip journal -recover -backward "*" 2>$gtm_tmp/"$USER"_$timestamp"_mupip_recover" && \
	$gtm_dist/mupip set -journal="on,before" -region "*" 2>$gtm_tmp/"$USER"_$timestamp"_mupip_set" && \
	find . -name \*.mjl_\* -mtime +$gtm_retention -exec rm -vf {} \; )
    if [ 0 = $# ] ; then
	$gtm_dist/mupip
    else
	$gtm_dist/mupip $*
    fi
    ( cd `dirname $gtmgbldir` \
	$gtm_dist/mupip rundown -region "*" 2>$gtm_tmp/"$USER"_$timestamp"-"`date -u +%Y%m%d%H%M%S`"UTC_mupip_rundown" )
    find $gtm_tmp -name "$USER"_\* -mtime +$gtm_retention -exec rm -f {} \;
fi
