[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: laptop environment detection

> I've looked at switchconf, whereami, netenv, guessnet, intuitively,
> divine, laptop-net, and laptop-netconf (are there any others).

What is needed is a program that
* triggers on events (perhaps including a timer) to do 
  location redetection
* Detects the current location
* Modifies the configuration accordingly
* It should do all this without requiring the user to
  hand-craft too many configuration files and scripts

Any of the packages you mentioned could be improved to do all
these things, but none of them currently does them all.

netenv and switchconf look like manual file-switching utilities.

intuitively (which replaces divine) does file-switching based
on automatic detection of networks:
      Sends out ARP (address resolution protocol)
      requests and, depending on who answers, it
      configures the network  interface and default
      route.  It also links the files in
      /etc/intuitively/NETWORK into your root hierarchy

guessnet does the same thing, but does it by enhancing ifup.
(guessnet is a program that can be named as a "script" inside
a "mapping" construct in /etc/network/interfaces.)
Thus it integrates better with standard tools.

Whereami implements a state machine (it remembers where it was
last; detect.conf defines the state transitions; whereami.conf 
specifies actions to take on state transitions) and includes
some nice config-file-altering scripts.  However (1) its triggering
hooks are a bit imperfect right now, and (2) it does not integrate
properly with ifup.  First, whereami should not be called
in if-pre-up.d.  If whereami is going to be triggered by events,
it makes no sense for ifup to call whereami, but whereami should
call ifup after it has figured out the current location.
Alternatively, if we really want ifup to call whereami,
then the hook scripts should call ifup.  Second, whereami needs
a "mapping" script (of the same genus as guessnet) that will
report to ifup the logical interface to use, based on the whereami
location.  Hmm ... this shouldn't be hard.  The following script
should do if there is only one location:
   loc=`cat /etc/whereami/iam`
   awk '$1 ~ /'"$loc"'/ { print $2 }'
This looks up the current location name in the table defined
by consecutive "map" lines in /etc/network/interfaces
and prints the interface name mapped to it, which ifup
can then bring up as it is configured to do.  Here is an example
of an interfaces file that works with the above script:
   auto lo
   iface lo inet loopback
   mapping eth0
      script /usr/sbin/thescriptabove
      map home eth0-home
   iface eth0-home inet static
Other network configuration can be done in pre-up and (post-)up
scripts.  This could include things like backing up files onto a
docking station.  Thus, one could add the lines
      up bind-forwarders
and such.

Thomas Hood <jdthood@yahoo.co.uk>

Reply to: