You are not logged in.

#1 2009-10-26 23:06:04

iosonofabio
Member
From: Australia
Registered: 2008-10-09
Posts: 105

netcfg POST_UP: setting environment variable

Hi!

I use netcfg to manage my network connections (ethernet and wireless). I want to set some environment variables after connecting to a certain profile network. If I put:

POST_UP="export xxx=whatever"

it does not work. Netcfg connects successfully to the network, but the envvar is not set. Anyone has suggestions?

Offline

#2 2009-10-26 23:08:40

gog
Member
Registered: 2009-10-13
Posts: 103

Re: netcfg POST_UP: setting environment variable

hackish:call a scriptlet that does what you want

Offline

#3 2009-10-26 23:40:46

iosonofabio
Member
From: Australia
Registered: 2008-10-09
Posts: 105

Re: netcfg POST_UP: setting environment variable

Not working either. I'm trying the following script:

#!/bin/sh
#
# setting the proxy when connected to ILL Airport
if [ $# == 0 ]; then export http_proxy='http://proxy.ill.fr:8888';
elif [ $1 == '-d' ]; then unset http_proxy;
else echo "Argument invalid. Please use no arg for setting the proxy, and option -d for unsetting it."
fi

but env variables are not set from the script (not even when I execute only the script w/o touching netcfg). However, if I export them from the terminal it works.

Where is the error?

Offline

#4 2009-10-27 02:37:02

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: netcfg POST_UP: setting environment variable

i dont know if you are using gnome, but if you are, you could always set a variable with gconf-tool and then have your own bash profile query for it. if you dont you gconf, write a config file in etc wink

thats what ive done to set my proxy.

Offline

#5 2009-10-27 03:21:06

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: netcfg POST_UP: setting environment variable

Setting an environment variable does not change it for the whole system. Setting an environment variable only affects that process and it's children. So setting a proxy like that won't work. Your login and desktop session is not started by netcfg (and shouldn't be).

If you want to set it via netcfg, you could use POST_UP/POST_DOWN to create a file in /etc/profile.d/. That gets loaded during your login, and will effect your session

_however_ if you disconnect from the network, the environment variable will still be set in your session until you relogin.

Last edited by iphitus (2009-10-27 03:21:50)

Offline

#6 2009-10-27 07:37:46

iosonofabio
Member
From: Australia
Registered: 2008-10-09
Posts: 105

Re: netcfg POST_UP: setting environment variable

Thank you for the replies.

First of all, I'm not using Gnome. So the gconf solution would not work.

Secondly, I use to login into my session and only then decide where to connect, which settings to apply etc. It hardly makes sense for me to set the proxy settings for the whole session, let aside doing it before logging in.

But there should be another way. How does Gnome do change the env var without asking the user to log out? Moreover, I'm aware of libproxy which is supposed to alter the proxy env var for all applications. How does it do that? Would it be feasible to let netcfg use libproxy (if installed) to set the proxy settings?

Offline

Board footer

Powered by FluxBB