summaryrefslogtreecommitdiff
path: root/checkaddr.sh
blob: 1b636f92ece654c6a82140c90c7a768c4436ce24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

if [ -z "$1" ] ; then
    IP=8.8.8.8
else
    IP=$1
fi

STATE=-1

while true ; do
    ping -c 1 -t 5 $IP > /dev/null

    STATUS=$?

    if [ $STATUS -ne $STATE ] ; then
    	STATE=$STATUS

	if [ $STATE -eq 0 ] ; then
	    echo $(date): Connnected to $IP
	else
	    echo $(date): Disconnected from $IP
	fi
    fi

    sleep 60
done