diff -p -up dhcp-4.1.1/client/scripts/linux.ifup dhcp-4.1.1/client/scripts/linux --- dhcp-4.1.1/client/scripts/linux.ifup 2009-04-21 11:21:09.000000000 -0300 +++ dhcp-4.1.1/client/scripts/linux 2010-02-25 11:26:32.000000000 -0300 @@ -1,8 +1,11 @@ #!/bin/bash -# dhclient-script for Linux. Dan Halbert, March, 1997. -# Updated for Linux 2.[12] by Brian J. Murrell, January 1999. -# No guarantees about this. I'm a novice at the details of Linux -# networking. +# Network Interface Configuration System +# +# Based on: +# dhclient-script for Linux. Dan Halbert, March, 1997. +# Updated for Linux 2.[12] by Brian J. Murrell, January 1999. +# Modified for Mandriva Linux 1999-2009 + # Notes: @@ -26,35 +29,46 @@ ip=/sbin/ip make_resolv_conf() { + local d + local ns + + if [ -n "$DOMAIN" ]; then + d="search $DOMAIN" + fi + if [ x"$new_domain_name_servers" != x ]; then - cat /dev/null > /etc/resolv.conf.dhclient - chmod 644 /etc/resolv.conf.dhclient - if [ x"$new_domain_search" != x ]; then - echo search $new_domain_search >> /etc/resolv.conf.dhclient + if [ -n "$DOMAIN" ]; then + # already done above + d="search $DOMAIN" + elif [ x"$new_domain_search" != x ]; then + d="search $new_domain_search" elif [ x"$new_domain_name" != x ]; then # Note that the DHCP 'Domain Name Option' is really just a domain # name, and that this practice of using the domain name option as # a search path is both nonstandard and deprecated. - echo search $new_domain_name >> /etc/resolv.conf.dhclient + d="search $new_domain_name" fi for nameserver in $new_domain_name_servers; do - echo nameserver $nameserver >>/etc/resolv.conf.dhclient + ns="$ns"$'\n'"nameserver ${nameserver}" done - mv /etc/resolv.conf.dhclient /etc/resolv.conf elif [ "x${new_dhcp6_name_servers}" != x ] ; then - cat /dev/null > /etc/resolv.conf.dhclient6 - chmod 644 /etc/resolv.conf.dhclient6 - if [ "x${new_dhcp6_domain_search}" != x ] ; then - echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 + if [ -n "$DOMAIN" ]; then + # already done above + d="search $DOMAIN" + elif [ "x${new_dhcp6_domain_search}" != x ] ; then + d="search ${new_dhcp6_domain_search}" fi for nameserver in ${new_dhcp6_name_servers} ; do - echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 + ns="$ns"$'\n'"nameserver ${nameserver}" done + fi - mv /etc/resolv.conf.dhclient6 /etc/resolv.conf + if [ -n "$d" -o -n "$ns" ]; then + change_resolv_conf "$d" "$ns" fi + } # Must be used on exit. Invokes the local dhcp client exit hooks, if any. @@ -78,6 +92,25 @@ if [ -f /etc/dhclient-enter-hooks ]; the fi fi +# Import Mandriva Linux configuration +cd /etc/sysconfig/network-scripts; +. /etc/sysconfig/network-scripts/network-functions +. /etc/rc.d/init.d/functions + +[ -f ../network ] && . ../network +[ -f ../networking/network ] && . ../networking/network + +CONFIG=$interface + +need_config ${CONFIG} + +if [ -f "${CONFIG}" ]; then + source_config +else + echo $"$0: configuration for $interface not found." >&2 + DEVICE=$interface +fi + ### ### DHCPv4 Handlers ### @@ -128,15 +161,6 @@ fi if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then - current_hostname=`hostname` - if [ x$current_hostname = x ] || \ - [ x$current_hostname = "x(none)" ] || \ - [ x$current_hostname = xlocalhost ] || \ - [ x$current_hostname = x$old_host_name ]; then - if [ x$new_host_name != x$old_host_name ]; then - hostname "$new_host_name" - fi - fi if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ [ x$alias_ip_address != x$old_ip_address ]; then @@ -155,12 +179,14 @@ if [ x$reason = xBOUND ] || [ x$reason = ifconfig $interface inet $new_ip_address $new_subnet_arg \ $new_broadcast_arg $mtu_arg # Add a network route to the computed network address. + if [ "${PEERGATEWAY}" != "no" ]; then for router in $new_routers; do if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then route add -host $router dev $interface fi route add default gw $router $metric_arg dev $interface done + fi fi if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; then @@ -168,7 +194,25 @@ if [ x$reason = xBOUND ] || [ x$reason = ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg route add -host $alias_ip_address $interface:0 fi - make_resolv_conf + if [ -n "$METRIC" ]; then + ifmetric $interface $METRIC + fi + if [ "${PEERDNS}" != "no" ]; then + make_resolv_conf + fi + if [ "${NEEDHOSTNAME}" = "yes" ]; then + if [ -z "$new_host_name" ]; then + eval `/bin/ipcalc --silent --hostname $new_ip_address` + new_host_name=$HOSTNAME + fi + if [ -n "$new_host_name" ]; then + current_hostname=`hostname` + + if [ "$new_host_name" != "$current_hostname" ]; then + set_hostname $new_host_name + fi + fi + fi exit_with_hooks 0 fi @@ -202,13 +246,17 @@ if [ x$reason = xTIMEOUT ]; then ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg route add -host $alias_ip_address dev $interface:0 fi + if [ "${PEERGATEWAY}" != "no" ]; then for router in $new_routers; do if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then route add -host $router dev $interface fi route add default gw $router $metric_arg dev $interface done + fi + if [ "${PEERDNS}" != "no" ]; then make_resolv_conf + fi exit_with_hooks 0 fi ifconfig $interface inet 0 down