#!/bin/bash

. ./param_bash.ini

clear
if [ "$FTP_SERVER" == "" ] ; then
    INFORM "The parameter FTP_SERVER is not defined"
    INFORM "Do you want me to find the best ftp for you?"
    CONFIRM
    if [ "$?" = "0" ] ; then
        bash check_best_ftp
        . ./param_bash.ini
    else
       ERROR "Set the parameter FTP_SERVER in param_bash.ini and rerun this step"
    fi
    if [ "$FTP_SERVER" == "" ] ; then
        ERROR "No FTP_SERVER where found in param_bash.ini file please set the parameter and rerun this step" "$0"
    fi
fi

START "Check if the Rosetta and Oracle software was downloaded properly" "$0"

$PS | grep -v grep | grep ftp_listener_ > /dev/null 2>&1
if [ "$?" = "0" ] ; then
    echo  "The Rosetta software download processes are still running"
    echo "press Enter key to continue"
    read
    exit 1
fi

WAIT "Checking"

bash -f ftp_listener_ver "$FTP_TEMPL_VER" "$IKIT_FTP_DIR" "$MAIL"
if [ "$?" = "0" ] ; then
	bash -f ftp_listener_prd "$FTP_TEMPL_PRD" "$IKIT_FTP_DIR" "$MAIL"
	if [ "$?" = "0" ] ; then
		DONE "The Rosetta and Oracle software was downloaded properly" "$0"
	else
		ERROR "The Oracle software download was failed , please check the ftp log files" "$0"
	fi
else
	ERROR "The Rosetta software download was failed , please check the ftp log files" "$0"
fi
