#!/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 Oracle software was downloaded properly" "$0"

$PS | grep -v grep | grep ftp_listener_db
if [ "$?" = "0" ] ; then
    echo "The Rosetta Oracle DB download processes are still running" "$0"
    echo "press Enter to continue"
    read 
    exit 1
fi

WAIT "Checking"

bash -f ftp_listener_db "$FTP_TEMPL_DB" "$IKIT_FTP_DIR" "$MAIL" 
if [ "$?" = "0" ] ; then
    DONE "The Rosetta Oracle DB was downloaded properly" "$0"
else
    ERROR "The Rosetta Oracle DB download was failed , please check the ftp log files" "$0"
fi 
