Skip to content

Commit 15adb11

Browse files
committed
add support for MacOSX.. don't look up host names when running
arp... support not initalizing interface MTU when first run, as this causing route and IP flush on MacOSX...
1 parent 66580a1 commit 15adb11

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

automtud.sh

+20-9
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ function process(oldmac, newmac)
5252
}
5353
5454
BEGIN {
55-
cmd = "arp -a; sleep 1"
55+
cmd = "arp -an; sleep 1"
5656
for (;;) {
5757
res=cmd | getline
58+
#system("echo '"'"'" $0 "'"'"' >&2")
5859
if (res == 0) {
5960
close(cmd)
6061
#print "processing" >"/dev/stderr"
@@ -69,7 +70,9 @@ BEGIN {
6970
print "error!" >"/dev/stderr"
7071
continue
7172
}
72-
if ($7 == "permanent" || $4 == "(incomplete)" || $6 !~ /'"$interfaces"'/)
73+
# broadcast is to support MacOSX
74+
# $8 is to support MacOSX
75+
if ($4 == "ff:ff:ff:ff:ff:ff" || $4 == "(incomplete)" || $7 == "permanent" || $8 == "permanent" || $6 !~ /'"$interfaces"'/)
7376
continue
7477
7578
newmac[substr($2, 2, length($2) - 2)] = $6
@@ -245,14 +248,17 @@ run_tests()
245248

246249
usage()
247250
{
248-
echo "Usage: $0 [ -m <minmtu> ] -i <interface> ..."
251+
echo "Usage: $0 [ -n ] [ -m <minmtu> ] -i <interface> ..."
252+
echo ""
253+
echo "For more information, see: https://github.com/jmgurney/automtud"
249254
}
250255

251256
# XXX - params
252257
interfaces=""
258+
nosetup="0"
253259
normal_mtu="1500"
254260

255-
while getopts hi:m:t opt; do
261+
while getopts hi:m:nt opt; do
256262
case "$opt" in
257263
i)
258264
xint="${OPTARG%%[^a-zA-Z0-9.]*}"
@@ -267,6 +273,9 @@ while getopts hi:m:t opt; do
267273
interfaces="$interfaces|$OPTARG"
268274
fi
269275
;;
276+
n)
277+
nosetup=1
278+
;;
270279
m)
271280
xint="${OPTARG%%[^0-9]*}"
272281
if [ x"$xint" != x"$OPTARG" ]; then
@@ -292,11 +301,13 @@ if [ -z "$interfaces" ]; then
292301
fi
293302

294303
# Get interfaces ready.
295-
for i in $(echo "$interfaces" | sed -e 's/|/\
296-
/g'); do
297-
echo setting up: "$i"
298-
setupinterface "$i"
299-
done
304+
if [ x"$nosetup" = x"0" ]; then
305+
for i in $(echo "$interfaces" | sed -e 's/|/\
306+
/g'); do
307+
echo setting up: "$i"
308+
setupinterface "$i"
309+
done
310+
fi
300311

301312
# Watch for machines comming and going and adjust as needed.
302313
detectmachines "$interfaces" | while read mode mach iface; do

0 commit comments

Comments
 (0)