Menu

[r10367]: / legacy / etc / rc.initial.ping  Maximize  Restore  History

Download this file

46 lines (37 with data), 984 Bytes

#!/bin/sh
#
# rc.initial.ping
# Copyright (c) 2006-2009 Volker Theile (votdev@gmx.de)
#
# part of FreeNAS (http://www.freenas.org)
# Copyright (C) 2005-2009 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
	echo

	# Check if it is a IPv4 address
	is_validip inet ${value}
	if [ 0 -eq $? ]; then
		echo "IPv4 address detected..."
		ping -c 3 -n ${value}
	else
		# Check if it is a IPv6 address
		is_validip inet6 ${value}
		if [ 0 -eq $? ]; 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
	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.