~peter-pearse/ubuntu/natty/ifupdown/prop001

« back to all changes in this revision

Viewing changes to _darcs/current/examples/ping-places.sh

  • Committer: Steve Langasek
  • Date: 2010-06-03 11:43:07 UTC
  • mfrom: (2.1.5 sid)
  • Revision ID: vorlon@debian.org-20100603114307-nu3s74dsmuvcclge
merge Debian version 0.6.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
if [ `id -u` -ne 0 ] || [ "$1" = "" ]; then exit 1; fi
 
4
 
 
5
if [ -x /usr/bin/fping ]; then
 
6
        PING="/usr/bin/fping"
 
7
else
 
8
        PING="/bin/ping -c 2"
 
9
fi
 
10
 
 
11
iface="$1"
 
12
which=""
 
13
 
 
14
while read addr pingme scheme; do
 
15
        if [ "$which" ]; then continue; fi
 
16
 
 
17
        #echo "  Trying $addr & $pingme ($scheme)" >&2
 
18
 
 
19
        ip addr add $addr dev $iface  >/dev/null 2>&1
 
20
        ip link set $iface up         >/dev/null 2>&1
 
21
 
 
22
        if $PING $pingme >/dev/null 2>&1; then
 
23
                which="$scheme" 
 
24
        fi
 
25
        ip link set $iface down       >/dev/null 2>&1
 
26
        ip addr del $addr dev $iface  >/dev/null 2>&1
 
27
done
 
28
 
 
29
if [ "$which" ]; then echo $which; exit 0; fi
 
30
exit 1