integ/utilities/platform-util/scripts/connectivity_test
Scott Little 1ead900a8f Relocate platform-util to stx-integ/utilities/platform-util
Move content from stx-utils into stx-integ or stx-update

Packages will be relocated to

stx-update:
    enable-dev-patch
    extras

stx-integ:
    config-files/
        io-scheduler

    filesystem/
        filesystem-scripts

    grub/
        grubby

    logging/
        logmgmt

    tools/
        collector
        monitor-tools

    tools/engtools/
        hostdata-collectors
        parsers

    utilities/
        build-info
        branding   (formerly wrs-branding)
        platform-util

Change-Id: I8ee29b0511085355ebca37fd46afe087fbd00ea8
Story: 2002801
Task: 22687
Signed-off-by: Scott Little <scott.little@windriver.com>
2018-08-01 12:26:20 -04:00

59 lines
1.1 KiB
Bash

#! /bin/bash
#
# Copyright (c) 2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
usage ()
{
echo "Usage: `basename $0` [-t TIMEOUT] [-i INTERFACE] DEST"
echo "Tests connectivity to DEST (hostname or IP). Test is done with ping/ping6."
echo ""
echo "Options:"
echo " -t TIMEOUT how long to wait before failing - defaults to 70 seconds"
echo " -i INTERFACE interface to use for ping - default is to allow ping command to select interface"
exit 1
}
TIMEOUT=70
IFARG=""
while getopts t:i: opt; do
case $opt in
t)
TIMEOUT=$OPTARG
;;
i)
INTERFACE=$OPTARG
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z $1 ]; then
usage
fi
if [ ! -z "$INTERFACE" ]; then
IFARG="-I $INTERFACE"
IFMSG="over interface $INTERFACE"
fi
DEST=$1
echo "Checking connectivity to $DEST for up to $TIMEOUT seconds $IFMSG"
while [ "$SECONDS" -le "$TIMEOUT" ]; do
ping -c 1 $IFARG $DEST > /dev/null 2>&1 || ping6 -c 1 $IFARG $DEST > /dev/null 2>&1
if [ $? -eq 0 ]
then
exit 0
fi
sleep 1
done
exit 1