diff --git a/SMP-analyze.sh b/SMP-analyze.sh index 2a5972ff2adb4e1ec08676a9cc07bc56ab292671..2d74fc16d1e3e8f7b44ba6b45fa59c3d34978911 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