
#======================================================
# SCMS-SM VCS agents
# TimesTenRep agent - open
# Created: Aug 2004
#======================================================
# Developed to start the TimesTen Replication agent resource
# the scripts runs the following algorithm:
# - checks input arguments
# - checks whether the replication process is running,
#   whether the replication is running and whether the 
#   replication state is OK.
# - if there is a recoverable problem the replication is restarted
# - if the subscriber database (local) is in a fatal state the 3007067 error
#   is logged and the user must recover by his self.
# - the script returns 1 or 0 if the replication is up or down accordingly.
#======================================================
# Modification list:
# 5/8/2004: created
#
#======================================================
# Messages Used:
# MSGID               Message
#------------------------------------------------------
# 37062: TimesTenRep:%s:%s: invalid path to the TimesTen replication agent '%s'
# 37063: TimesTenRep:%s:%s: 
# 37064: TimesTenRep:%s:%s: 
# 37065: TimesTenRep:%s:%s: parameters: %s, %s
#======================================================

eval 'exec $VCS_HOME/bin/perl5 -S $0 ${1+"$@"}'
        if 0;
($ResID, $TtBinPathname, $DebugLevel) = @ARGV;

use TtOperations;
use Args;


#
# Set the OS locale
#
$ENV{"LANG"}="C";

$vcs_home =$ENV{"VCS_HOME"} || "/opt/VRTSvcs";
my ( $log_message );

$TtBinPathname = cleanString($TtBinPathname);

use ag_i18n_inc;
VCSAG_SET_ENVS ("TimesTenRep", "open",$category_id);

if (($TtBinPathname eq "") || ( ! -d $TtBinPathname )) {
   VCSAG_LOG_MSG("E"," invalid path to the TimesTen replication agent '$TtBinPathname'",37062,"$TtBinPathname");
   exit 0;
}


$Threshold = 20;

if ($DebugLevel > 0) 
{
   VCSAG_LOG_MSG("I"," parameters: $TtBinPathname, $DebugLevel","$ResID", "$TtBinPathname", "$DebugLevel");
}

my %args2 = ("EntryType" => "open",
               "ResID" => $ResID,
               "TtBinPathname" => $TtBinPathname,
               "DebugLevel" => $DebugLevel,
               "Threshold" => $Threshold);

my $startResult = makeSureRepIsUp(\%args2);
                                             
if ($startResult > 0)                        
{                                            
   exit 0;                                   
}                                            
else                                         
{                                            
   exit 1;                                   
}   

