#!/bin/bash -e

if [ $# -eq 0 ] ; then
    echo "SDI Server IP must be entered"
    exit
fi

SDI_SERVER_IP=$1

echo $SDI_SERVER_IP
nslookup $SDI_SERVER_IP 

if [ $? != 0 ] ; then
    echo "SDI Server Not Found"
    exit 
fi

#
# This amqpfind command triggers off a python script when a band end has completed
#
echo "Starting sftp using RabbitMQ events"
echo "$HOME/Client-Testing/amqpfind/amqpfind -p guest -u guest -H $SDI_SERVER_IP -C geo.goes.g16.abi.*.*.*.*.end | xargs -P1 -n2 python $HOME/Client-Testing/scripts/sftp-event.py"
$HOME/Client-Testing/amqpfind/amqpfind -p guest -u guest -H $SDI_SERVER_IP -C geo.goes.g16.abi.*.*.*.*.end | xargs -P1 -n2 python $HOME/Client-Testing/scripts/sftp-event.py 

#
# This amqpfind command triggers off a python script when an entire image has completed
#
#echo "$HOME/Client-Testing/amqpfind/amqpfind -p guest -u guest -H $SDI_SERVER_IP -C geo.goes.g16.abi.*.*.*.*.end | xargs -P1 -n2 python $HOME/Client-Testing/scripts/sftp-event.py "
#$HOME/Client-Testing/amqpfind/amqpfind -p guest -u guest -H $SDI_SERVER_IP -C geo.goes.g16.abi.*.*.*.*.complete | xargs -P1 -n2 python $HOME/Client-Testing/scripts/sftp-event.py 
exit 0
