[WHEREAMI] Assistance with detect.conf?

Chris Dunning chris at bluenoteweb.com
Fri Nov 4 05:48:06 NZDT 2005


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.

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

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

# 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

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

# 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

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

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?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chris.vcf
Type: text/x-vcard
Size: 272 bytes
Desc: not available
Url : http://lists.catalyst.net.nz/pipermail/whereami-discuss/attachments/20051103/0382966c/chris.vcf


More information about the whereami-discuss mailing list