What is the best way to set variables depending on environment?

Magnus Therning magnus at therning.org
Wed Sep 7 19:20:46 UTC 2005


On Wed, Sep 07, 2005 at 04:26:22PM +0300, janne.jokitalo at dnainternet.net wrote:
>Hello all,
>
>I'm bringing my laptop home from work every day, and I'd need to unset
>the various proxy settings for different applications each time after
>I've ifup'd the wireless network. For now I've just made the change to
>each program I'd use (and had used at work too), but since many are now
>able to use the 'http_proxy' variable, I was thinking, couldn't a
>script automatically set/unset that variable depending on which IP
>address my machine got after requesting one from a DHCP server? They
>are distinguishable, as at work the IP begins with 10.*, but my home
>network uses 192.168.* addresses.
>
>Well, that wass kind of a rhetorical question, my real one is how to
>best do this? I was thinking, maybe adding a line to ifupdown script to
>fire another after successfully set an IP. But then, if the script gets
>updated automatically during a dist-upgrade or something, wouldn't I
>lose that change? I know dpkg (or is that debconf?) asks before
>altering a configuration file if it recognizes user-made changes, and I
>know it isn't a big change to be made after the update, but still,
>there probably are more elegant ways of doing this, right?
>
>Thanks in advance for any possible solutions!

Have you looked at the package laptop-netconf? It seems to be aimed at
the sort of thing you are talking about.

Let me know how it works out, I'll hopefully be in your situation in a
few weeks (all hinging on BT getting their arse into gear)...

/M

-- 
Magnus Therning                    (OpenPGP: 0xAB4DFBA4)
magnus at therning.org
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Any spelling errors in the above are due to a known bug in my wetware.
Please route all spelling related flames or spelling corrections to
/dev/null.
Fixed in Magnus-r2.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20050907/2f78af03/attachment.sig>


More information about the ubuntu-users mailing list