--- mcore-src/trunk/mcore-tools/daemon/client/include/network.client.class 2011/02/04 20:01:16 1260 +++ mcore-src/trunk/mcore-tools/daemon/client/include/network.client.class 2011/03/10 18:14:47 1646 @@ -5,21 +5,56 @@ help_network_hostname() { + mecho "get network.hostname" + mecho " displays the current hostname" + mecho mecho "set network.hostname [hostname]" + mecho " Sets the hostname of the system" mecho " mcore - the local hostname" } +get_network_hostname() +{ + hostname +} + # set_network_hostname $value set_network_hostname() { local value="$1" local CONFIG + local socket + local cookie + local authtype + [[ -z ${value} ]] && help_network_hostname && return 1 CONFIG="/etc/hostname" clearconfig addconfig "${value}" hostname "${value}" + + # update hosts file + CONFIG="/etc/hosts" + clearconfig + addconfig "127.0.0.1 localhost ${value}" + # add ipv6 defaults + addconfig "::1 ip6-localhost ip6-loopback" + addconfig "fe00::0 ip6-localnet" + addconfig "ff00::0 ip6-mcastprefix" + addconfig "ff02::1 ip6-allnodes" + addconfig "ff02::2 ip6-allrouters" + addconfig "ff02::3 ip6-allhosts" + + # check for running x11 and recreate the xauth cookie with the correct hostname + if [[ ! -z $(pidof X) ]] + then + socket="${value}/unix${MCORE_XORG_DISPLAY}" + cookie=$(x11runas "xauth list | sed 's:.*\ \(.*\):\1:'") + authtype="MIT-MAGIC-COOKIE-1" + # add the new hostname to the xauthority file + x11runas "xauth add ${socket} ${authtype} ${cookie}" + fi } help_network_iface() @@ -80,12 +115,30 @@ fi } -set_network_default_gw() +help_network_gateway() +{ + mecho "get network.gateway" + mecho " displays the current network gateway" + mecho + mecho "set network.gateway [ip]" + mecho " sets the network gateway to [ip]" +} + +get_network_gateway() +{ + local gw + gw=$(ip route | grep default | sed 's:.*via[[:space:]]\(.*\)[[:space:]]dev.*:\1:') + rvecho "${gw}" +} + +set_network_gateway() { - local value + local value="$1" local CONFIG local i + [[ -z ${value} ]] && help_network_gateway && return 1 + CONFIG="/etc/conf.d/net.routes" clearconfig addconfig "default gw ${value}" @@ -98,12 +151,35 @@ route add default gw "${value}" } -set_network_dns() +help_network_nameserver() +{ + mecho "get network.nameserver" + mecho " displays the current nameserver of the system" + mecho + mecho "set network.nameserver [ip1] [ip2] .. [ipN]" + mecho " adds given ips as nameserver to the system" +} + +get_network_nameserver() +{ + local dns + local i + + dns=$(grep nameserver /etc/resolv.conf | sed 's:.*[[:space:]]\(.*\):\1:g') + for i in ${dns} + do + rvecho "${i}" + done +} + +set_network_nameserver() { local values="$@" local CONFIG local i + [[ -z ${values} ]] && help_network_nameserver && return 1 + CONFIG="/etc/resolv.conf" clearconfig for i in ${values}