Changing JDS/Solaris 10 proxy settings

I guess this should go into the Gnome category, but I'm too lazy to create one:). Yesterday I finally wrote the magic script that automatically sets the proxy properties of Gnome depending on the ip address the notebook got from DHCP. It could be useful for others running JDS or Gnome who change between networks (home, office, customer, etc) a lot. This one works on Solaris, but you may customize the ifconfig part to run on Linux as well.

#!/bin/ksh

# ethernet interface to query for ip address
IFACE=rtls0
# proxy to set
SUNPROXY=xxxxxxxxxxxx
SUNPORT=8080

# function to set a gconf parameter via gconftool-2
set_gconf() {
  gconftool-2 \\
        --type $1 --set $2 "$3"
}

# fetch the ip address of the specified interfaced
ipaddress=`/sbin/ifconfig $IFACE | grep inet | awk ' { print $2 } ' `

# HOME NAT
if echo $ipaddress | egrep 192.168
then
  set_gconf string /system/proxy/mode none
  set_gconf bool /system/http_proxy/use_http_proxy false
  exit 0
fi

# Sun Office
if echo $ipaddress | egrep 129.159
then
  set_gconf string /system/proxy/mode manual
  set_gconf string /system/proxy/secure_host $SUNPROXY
  set_gconf string /system/proxy/ftp_host $SUNPROXY
  set_gconf int /system/proxy/secure_port $SUNPORT
  set_gconf int /system/proxy/ftp_port $SUNPORT

  set_gconf bool /system/http_proxy/use_http_proxy true
  set_gconf string /system/http_proxy/host $SUNPROXY
  set_gconf int /system/http_proxy/port $SUNPORT
  exit 0
fi

# Unknown network, disable proxy
set_gconf string /system/proxy/mode none
set_gconf bool /system/http_proxy/use_http_proxy false

If only the gaim version shipped with JDS used these global settings... gnome-session-properties can be used to make this script run automaticaly every time you log into JDS.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

csj

Search

Archives
« április 2014
HKSzeCsPSzoV
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today