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

janne.jokitalo at dnainternet.net janne.jokitalo at dnainternet.net
Wed Sep 7 13:26:22 UTC 2005


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!


-- 
Jaska




More information about the ubuntu-users mailing list