Menu

[r3313]: / trunk / etc / rc.initial.ping  Maximize  Restore  History

Download this file

38 lines (30 with data), 881 Bytes

#!/bin/sh
#
# rc.initial.ping
# Copyright (c) 2006-2008 Volker Theile (votdev@gmx.de)
#
# part of FreeNAS (http://www.freenas.org)
# Copyright (C) 2005-2008 Olivier Cochard <cochard@gmail.com>.
# All rights reserved.

. /etc/util.subr

tmpfile=`tmpfile 2>/dev/null` || tmpfile=/tmp/tui$$
trap "rm -f $tmpfile" 0 1 2 5 15

/usr/local/bin/cdialog --clear --inputbox "Enter a host name or IP address." 8 50 2> $tmpfile

retval=$?
value=`cat $tmpfile`

[ -z "${value}" ] && exit 0

if [ 0 -eq ${retval} ]; then
	if [ ! `is_validip inet ${value}` ]; then
		echo "IPv4 address detected..."
		ping -c 3 -n ${value}
	elif [ ! `is_validip inet6 ${value}` ]; then
		echo "IPv6 address detected..."
		ping6 -c 3 -n ${value}
	else
		echo "Hostname supposed, trying IPv4 and IPv6 ping..."
		ping -c 3 -n ${value}
		ping6 -c 3 -n ${value}
	fi

	echo
	read -p "Press ENTER to continue." value
fi
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.