scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 85987e819a85fa20b3aa6366dae7a27df624ee8a
parent 5799b414fd9ac32c2ffb099907e9a9d9f4e2c39a
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sat, 17 Dec 2016 11:16:56 +0100

[iwpick] Wait for the gateway packet.

Diffstat:
Msrc/iwpick | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/iwpick b/src/iwpick @@ -23,11 +23,14 @@ connect() { fi sdhcp -d $iface >/dev/null & - pkt="$(tcpdump -vlni $iface -c 1 -Q in udp 2>&1)" - addr="$(echo "$pkt" |grep "Your-IP" |tr -d [:space:] |cut -b8-)" - dgw="$(echo "$pkt" |grep "Gateway-IP" |tr -d [:space:] |cut -b11-)" - egw="$(echo "$pkt" |grep "Default-Gateway" |tr -d [:space:] |cut -d: -f2)" - [ -n "$dgw" ] && gw="$dgw" || gw="$egw" + + while [ -z "$gw" ]; do + pkt="$(tcpdump -vlni $iface -c 1 -Q in udp 2>&1)" + addr="$(echo "$pkt" |grep "Your-IP" |tr -d [:space:] |cut -b8-)" + dgw="$(echo "$pkt" |grep "Gateway-IP" |tr -d [:space:] |cut -b11-)" + egw="$(echo "$pkt" |grep "Default-Gateway" |tr -d [:space:] |cut -d: -f2)" + [ -n "$dgw" ] && gw="$dgw" || gw="$egw" + done ifconfig $iface $addr route add default gw $gw }