[WHEREAMI] Assistance with detect.conf?

Andrew McMillan andrew at catalyst.net.nz
Fri Nov 4 22:43:02 NZDT 2005


On Thu, 2005-11-03 at 10:48 -0600, Chris Dunning wrote:
> This script looks like exactly what I need.  My situation:
> 
> My laptop goes with me all over the place.  Just about everywhere, I 
> need to connect to the available wireless AP and use DHCP for 
> configuration.  When I'm at home, however, I want a static IP so that my 
> overnight backup scripts can run.

This seems reasonable.  One thing I've found recently (I got a new
laptop last weekend :-) is that mii-tool will return a "Operation Not
Supported" on (most?) Gb network cards.  I have modified the testmii
script as a result so that it will fall back to using ethtool in that
case.

Possibly you are being bitten by this.  Check to see what you get when
you try 'mii-tool eth0' (you don't need to be on a network to test
that).  If you get "not supported" then upgrade to 3.28 and it should
work better.  The unstable packages of whereami should be fine on sarge
(or possibly even woody) since it is just using standard perl & bash
syntax.


> I've set up my detect.conf and I thought I had it right, but it's always 
> defaulting to wifi-roam even at home.  I've tried changing the order 
> around, I've tried using "!home-wifi" in the if statements, I've tried 
> using "notat wlan" but no go.  I tried using "elif" statements and those 
> didn't work either.  The basic goal is:
> -if plugged in, use the wired network
> -if not plugged in, try to use the home wifi network (essid bluenoteweb) 
> with static IP
> -if can't get on the home network, use any available wireless ap with dhcp
> 
>   Here's my current detect.conf:
> 
> # It is a good idea to default to somewhere...
> default wifi-roam

Well, it will default to that, of course...

> 
> # Test for the presence of an ethernet connection plugged into eth0
> testmii eth0 lan

See comment above.

> 
> # Uncomment this for exhaustive debugging output
> # set DEBUGWHEREAMI 1
> 
> # 'down' might be a location that is forced from the command line
> # like "whereami down"
> if down
>   always at undocked
>   always notat eth0,eth1
> elif stop
>   # Or maybe we can't remember the exact command, so we do it twice!
>   # like "whereami stop" this time
>   always at undocked
>   always notat eth0,eth1
> elif lan
>   # If the testmii at the top was successful
>   set INTERFACE eth0
>    testdhcp    '*.*.*.*'    dhcp
>   # testarp     eth0,00:24:5e:17:12:11,10.2.0.4  morrinsville
>   # testping    192.168.138.1,192.168.138.55     queenstown
>   # testping    202.49.41.18,202.49.41.1         rotorua
> else
>   # If the testmii at the top failed
>   # modprobe prism54 w_eth1
>   # always modprobe orinoco w_eth1
>   # always modprobe ath_pci atheros
>   # always modprobe ipw2100 w_eth1
>   # ... and we unload this in whereami.conf, if we don't find one,
>   # in an attempt to minimise power, and RFI
> fi
> 
> if w_eth1
>   # Some wireless drivers use one interface name
>   set INTERFACE eth1
>   testap scan wlan
> fi

Unless you're setting 'atheros' some way that I don't understand the
next section will never be parsed, so you won't get the initial scan for
APs.

> if atheros
>   # And some use a different one
>   set INTERFACE ath0
>   testap scan wlan
> fi
> 

And since you won't have found any APs, "wlan" can't be true...

> # If we have found at least some WLAN APs in the vicinity, find out
> # if we can do anything with any of them
> # first check for the home network
> if wlan
>   testap bluenoteweb home-wifi
> fi

Or this...

> if wlan,!home-wifi
>   # testap      milford,1234-5FED-CB                      milford,wdhcp
>   # testap      wanaka,1234-2468-1357-dead-beef-feed-99  wanaka,wdhcp
>   # testap      ruapehu                 ruapehu,wdhcp
>   # # If there's anything there at all, try and DHCP off it
>   testap      .+                  wdhcp
>   # # And if there isn't, we will indicate that.
>   # notat  wlan,wdhcp
> fi

And if that wasn't, then this can't be either... and so on... so you end
up with the default.
> if home-wifi
>   echo home-wifi
>   at home-wifi
>   notat wdhcp
> fi
> 
> if wlan
>   echo wlan
> fi
> 
> if wdhcp
> # So it seems we should try and get DHCP off a WLAN AP
>   echo wdhcp
>   testdhcp    '*.*.*.*'    wifi-roam
> fi
> 
> # And if we have DHCP (wired or wireless) we want to make
> # a decision as to which LAN that is, exactly.
> if dhcp
>   # testdhcp    192.168.5.*     waiheke
>   # testdhcp    192.168.7.*     tauranga
>   # testdhcp    192.168.10.*    wellington
>   # testdhcp    192.168.55.3*   picton
>   # # Note that we only get here, if the one above is _unsuccessful_
>   # testdhcp    192.168.55.*    rakaia
> fi
> 
> 
> I've also tried:
> 
> if wlan
>   testap bluenoteweb home-wifi
>   testap .+ wdhcp
> fi
> 
> if home-wifi
>   echo home-wifi
> elif wdhcp
>   echo wdhcp
> fi
> 
> This set of code prints out both "home-wifi" and "wdhcp" - if I 
> understand shell scripting correctly, there's no way that it would 
> execute both portions of that.
> 
> What am I doing wrong here?

Hopefully that's clarified things somewhat for you.

Regards,
					Andrew.

-------------------------------------------------------------------------
Andrew @ Catalyst .Net .NZ  Ltd,  PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/            PHYS: Level 2, 150-154 Willis St
DDI: +64(4)803-2201      MOB: +64(272)DEBIAN      OFFICE: +64(4)499-2267
                   Be cautious in your daily affairs.
-------------------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.catalyst.net.nz/pipermail/whereami-discuss/attachments/20051104/6094a024/attachment.pgp


More information about the whereami-discuss mailing list