#!/bin/bash

ADDR=(240 241 242 243)
for i in "${ADDR[@]}"
do
    if ping -c1 -w2 192.168.3.$i &> /dev/null
    then
        if curl -u admin:  http://192.168.3.$i/config/sw_select | egrep -q ".*?ZOOX\.dat\|.*?\^"
        then
            if curl -u admin:  http://192.168.3.$i/config/sw_select | egrep -q ".*?v3\.66\.01\.470.*?\^"
            then
                echo Network switch at 192.168.3.$i is configured correctly
            else
                echo FAILED - Network switch at 192.168.3.$i has the wrong firmware version!

            fi
        else
            echo FAILED - Network switch at 192.168.3.$i does not have the Zoox firmware!
        fi
    else
        echo FAILED - could not ping 192.168.3.$i!
    fi
done
