Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/daemon/client/include/network.client.class

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1260 by niro, Fri Feb 4 20:01:16 2011 UTC revision 1351 by niro, Thu Feb 17 21:44:18 2011 UTC
# Line 5  require basic-system Line 5  require basic-system
5    
6  help_network_hostname()  help_network_hostname()
7  {  {
8     mecho "get network.hostname"
9     mecho " displays the current hostname"
10     mecho
11   mecho "set network.hostname [hostname]"   mecho "set network.hostname [hostname]"
12     mecho " Sets the hostname of the system"
13   mecho "  mcore - the local hostname"   mecho "  mcore - the local hostname"
14  }  }
15    
16    get_network_hostname()
17    {
18     hostname
19    }
20    
21  # set_network_hostname $value  # set_network_hostname $value
22  set_network_hostname()  set_network_hostname()
23  {  {
24   local value="$1"   local value="$1"
25   local CONFIG   local CONFIG
26     local socket
27     local cookie
28     local authtype
29    
30   [[ -z ${value} ]] && help_network_hostname && return 1   [[ -z ${value} ]] && help_network_hostname && return 1
31    
32   CONFIG="/etc/hostname"   CONFIG="/etc/hostname"
33   clearconfig   clearconfig
34   addconfig "${value}"   addconfig "${value}"
35   hostname "${value}"   hostname "${value}"
36    
37     # check for running x11 and recreate the xauth cookie with the correct hostname
38     if [[ ! -z $(pidof X) ]]
39     then
40     socket="${value}/unix${MCORE_XORG_DISPLAY}"
41     cookie=$(x11runas "xauth list | sed 's:.*\ \(.*\):\1:'")
42     authtype="MIT-MAGIC-COOKIE-1"
43     # add the new hostname to the xauthority file
44     x11runas "xauth add ${socket} ${authtype} ${cookie}"
45     fi
46  }  }
47    
48  help_network_iface()  help_network_iface()
# Line 80  set_network_iface() Line 103  set_network_iface()
103   fi   fi
104  }  }
105    
106  set_network_default_gw()  help_network_gateway()
107    {
108     mecho "get network.gateway"
109     mecho " displays the current network gateway"
110     mecho
111     mecho "set network.gateway [ip]"
112     mecho " sets the network gateway to [ip]"
113    }
114    
115    get_network_gateway()
116    {
117     local gw
118     gw=$(ip route | grep default | sed 's:.*via[[:space:]]\(.*\)[[:space:]]dev.*:\1:')
119     echo "${gw}"
120    }
121    
122    set_network_gateway()
123  {  {
124   local value   local value="$1"
125   local CONFIG   local CONFIG
126   local i   local i
127    
128     [[ -z ${value} ]] && help_network_gateway && return 1
129    
130   CONFIG="/etc/conf.d/net.routes"   CONFIG="/etc/conf.d/net.routes"
131   clearconfig   clearconfig
132   addconfig "default gw ${value}"   addconfig "default gw ${value}"
# Line 98  set_network_default_gw() Line 139  set_network_default_gw()
139   route add default gw "${value}"   route add default gw "${value}"
140  }  }
141    
142  set_network_dns()  help_network_nameserver()
143    {
144     mecho "get network.nameserver"
145     mecho " displays the current nameserver of the system"
146     mecho
147     mecho "set network.nameserver [ip1] [ip2] .. [ipN]"
148     mecho " adds given ips as nameserver to the system"
149    }
150    
151    get_network_nameserver()
152    {
153     local dns
154     local i
155    
156     dns=$(grep nameserver /etc/resolv.conf | sed 's:.*[[:space:]]\(.*\):\1:g')
157     for i in ${dns}
158     do
159     echo "${i}"
160     done
161    }
162    
163    set_network_nameserver()
164  {  {
165   local values="$@"   local values="$@"
166   local CONFIG   local CONFIG
167   local i   local i
168    
169     [[ -z ${values} ]] && help_network_nameserver && return 1
170    
171   CONFIG="/etc/resolv.conf"   CONFIG="/etc/resolv.conf"
172   clearconfig   clearconfig
173   for i in ${values}   for i in ${values}

Legend:
Removed from v.1260  
changed lines
  Added in v.1351