subes
October 28th, 2008, 10:07 PM
Hi,
i wrote a small networkmanager script that enabled/disables the proxy depending on the vpn connection state...
Im using gconftool-2 in that script to set the gconf values
The is placed as /etc/NetworkManager/dispatcher.d/02vpnproxy
and is executable.
#!/bin/bash
#Diese Werte werden vom NetworkManager an das Skript übergeben
INTERFACE=$1
ACTION=$2
#Hauptbenutzer finden
ON_USER=$(cat /etc/passwd | grep :1000: | cut -d ':' -f 1)
#echo $ON_USER
## Funktionen durchführen, je nach Aktion eine andere
case "$2" in
vpn-up)
gconftool --type string --set /system/proxy/mode manual
gconftool --type boolean --set /system/http_proxy/use_http_proxy true
su $ON_USER -c 'gconftool --type string --set /system/proxy/mode manual && gconftool --type boolean --set /system/http_proxy/use_http_proxy true'
;;
vpn-down)
gconftool --type string --set /system/proxy/mode none
gconftool --type boolean --set /system/http_proxy/use_http_proxy false
su $ON_USER -c 'gconftool --type string --set /system/proxy/mode none && gconftool --type boolean --set /system/http_proxy/use_http_proxy false'
;;
*)
echo $"Usage: $0 {vpn-up|vpn-down}"
;;
esac
The problem i have, is that the gconf values or not set
when i issue the commands as the normal user in console, the values get updated.
When login as root via "sudo su" and use "su <USER> -c '...'" the values are not updated.
Tho, when i login as root via "su" instead of "sudo su", the command works fine.
Why doesnt gconftool work all the time? It doesnt even print any errors.
Is there some better way to change the proxy via the networkmanager dispatcher and gconf?
Or why doesnt the script "just work"?
Ive tried quite some stuff, but im on a complete loss atm :(
i wrote a small networkmanager script that enabled/disables the proxy depending on the vpn connection state...
Im using gconftool-2 in that script to set the gconf values
The is placed as /etc/NetworkManager/dispatcher.d/02vpnproxy
and is executable.
#!/bin/bash
#Diese Werte werden vom NetworkManager an das Skript übergeben
INTERFACE=$1
ACTION=$2
#Hauptbenutzer finden
ON_USER=$(cat /etc/passwd | grep :1000: | cut -d ':' -f 1)
#echo $ON_USER
## Funktionen durchführen, je nach Aktion eine andere
case "$2" in
vpn-up)
gconftool --type string --set /system/proxy/mode manual
gconftool --type boolean --set /system/http_proxy/use_http_proxy true
su $ON_USER -c 'gconftool --type string --set /system/proxy/mode manual && gconftool --type boolean --set /system/http_proxy/use_http_proxy true'
;;
vpn-down)
gconftool --type string --set /system/proxy/mode none
gconftool --type boolean --set /system/http_proxy/use_http_proxy false
su $ON_USER -c 'gconftool --type string --set /system/proxy/mode none && gconftool --type boolean --set /system/http_proxy/use_http_proxy false'
;;
*)
echo $"Usage: $0 {vpn-up|vpn-down}"
;;
esac
The problem i have, is that the gconf values or not set
when i issue the commands as the normal user in console, the values get updated.
When login as root via "sudo su" and use "su <USER> -c '...'" the values are not updated.
Tho, when i login as root via "su" instead of "sudo su", the command works fine.
Why doesnt gconftool work all the time? It doesnt even print any errors.
Is there some better way to change the proxy via the networkmanager dispatcher and gconf?
Or why doesnt the script "just work"?
Ive tried quite some stuff, but im on a complete loss atm :(