#!/bin/bash - 
#===============================================================================
#
#          FILE: homeNetTesteroni.sh
# 
#         USAGE: ./homeNetTesteroni.sh 
# 
#   DESCRIPTION: 
# 
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Jandourek Jaroslav (), jandourek.jaroslav@gmail.com
#  ORGANIZATION: 
#       CREATED: 2.6.2019 18:20:53
#      REVISION:  ---
#===============================================================================

#testing connectivity
echo ""
echo "--------------------------------------------"
netping=$( ping 8.8.8.8 -c 1 )
netping=$( echo $netping | grep "0% packet loss," )
tunState=$( ifconfig tun0 2>/dev/null| grep "RUNNING " | awk {'print $1'} )
vpnState=$( ifconfig vpn0 2>/dev/null| grep "RUNNING " | awk {'print $1'} )
if  [ "$tunState" = "UP" ] || [ "$vpnState" = "UP" ] && [[ ${#netping} -ne 0 ]] 
then

	nmapresults=$( nmap 192.168.1.* )
	hostUp= echo $nmapresults | grep 192.168.1.108
	if [ ]
	echo "Network seems fine"
	#testing Host
	eval `ssh-agent -s`
		ssh-add /home/jarda/.ssh/masterBlaster
		#show me guestInfo
		for i in ${!up[@]} 
		do
			#check needed updates
			#show resource usgae
			#show uptime
			#show last login

			command=$( ssh jarda@192.168.1.${up[i]}  )	
		done


		echo "host is DOWN"
		echo "--------------------------------------------"


else
	echo "network is down and look at that VPN :$tunState $vpnState"
fi

