From bf3085f435f0ec8d1a160f2c8f5f0210cc3c6adf Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 23 Aug 2014 13:30:45 +0200 Subject: [PATCH] autodist-cgi: check if host is up before fetching cgi data from secondary sites --- autodist-cgi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/autodist-cgi b/autodist-cgi index 6bdeb7c..04048c4 100755 --- a/autodist-cgi +++ b/autodist-cgi @@ -358,10 +358,14 @@ done # only root host (0) calls other hosts if [ "$AS_HOST" = "0" -a ! "$SHOWLOG" ]; then for h in `seq 1 ${#AUTOPORT_CGI_HOST[*]}`; do - if [ "$NUM" -a "$HOST" = "$h" ]; then - curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&LINES=$LINES&NUM=$NUM&REP=$RNUM&HOST=$HOST" 2>/dev/null - elif [ ! "$NUM" ]; then - curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&LINES=$LINES" 2>/dev/null + WBHOSTURL=`echo ${AUTOPORT_CGI_HOST[$h]} | sed "s|^\(http[s]*://[^/]*\).*$|\1|"` + if [ "$WBHOSTURL" ]; then + curl -m1 -s -I ${WBHOSTURL} >/dev/null || continue + if [ "$NUM" -a "$HOST" = "$h" ]; then + curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&LINES=$LINES&NUM=$NUM&REP=$RNUM&HOST=$HOST" 2>/dev/null + elif [ ! "$NUM" ]; then + curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&LINES=$LINES" 2>/dev/null + fi fi done fi