#!/bin/bash

#set device ip
IP_STRING=$1

# let's ping TARGET -> even if target is ON, it doesn't mean network is alive. Always need to check.
ping -c 1 $IP_STRING &> /dev/null && target_alive=1 || target_alive=0

while [[ $target_alive -eq 1 ]];
do                  
    echo "PINGING THE BOARD IP $IP_STRING"

    sleep 5

    # let's ping TARGET -> even if target is ON, it doesn't mean network is alive. Always need to check.
    ping -c 1 $IP_STRING &> /dev/null && target_alive=1 || target_alive=0

    if [ $target_alive -eq 0 ]; then
        echo "The device $IP_STRING is not answering!!!"
        exit 7
    fi
done   
