From 9e2476a725d065032837077576e7dfbec1944e04 Mon Sep 17 00:00:00 2001 From: an7s <an7s@localhost> Date: Wed, 20 Apr 2016 21:27:20 +0000 Subject: [PATCH] Ping remote host to make sure live --- SMP-analyze.sh | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/SMP-analyze.sh b/SMP-analyze.sh index 2a5972f..2d74fc1 100755 --- a/SMP-analyze.sh +++ b/SMP-analyze.sh @@ -12,6 +12,17 @@ file=$1 md5name=$(md5sum $file | awk '{print $1}') directory=/tmp/remote-analyze/${md5name} +verify_host_live() +{ + remotehost=$1 + ping -c 5 -w 5 $remotehost + if [ ! $? -eq 0 ]; then + return 1 + fi + + return 0 +} + copy_STARS_info() { remotehost=$1 @@ -89,18 +100,30 @@ run_remote_command() # FIXME: need to handle multiple files to be analyzed? exit_code=1 -server_has_cached_info $IDA_PRO_SERVER_HOST -if [ $? -eq 0 ]; then - echo SERVER HAS ALREADY ANALYZED $md5name, retrieving cached info - copy_and_verify_result $remotehost $file.annot - exit_code=$? +verify_host_live $IDA_PRO_SERVER_HOST +if [ $? -eq 0 ]; then + server_has_cached_info $IDA_PRO_SERVER_HOST + if [ $? -eq 0 ]; then + echo SERVER HAS ALREADY ANALYZED $md5name, retrieving cached info + copy_and_verify_result $remotehost $file.annot + exit_code=$? + else + run_remote_command $IDA_PRO_SERVER_HOST $@ + exit_code=$? + fi else - run_remote_command $IDA_PRO_SERVER_HOST $@ - exit_code=$? + echo "Host $IDA_PRO_SERVER_HOST is not responding" fi if [ ! $exit_code -eq 0 ]; then echo "Error detected on primary $IDA_PRO_SERVER_HOST, failing over to $IDA_PRO_SERVER_HOST2" + + verify_host_live $IDA_PRO_SERVER_HOST2 + if [ ! $? -eq 0 ]; then + echo "Backup host $IDA_PRO_SERVER_HOST2 is not responding" + exit 1 + fi + run_remote_command $IDA_PRO_SERVER_HOST2 $@ exit_code=$? fi -- GitLab