--- dhcp-3.0.5/client/scripts/linux.ifup 2002-11-15 02:09:09.000000000 +0100 +++ dhcp-3.0.5/client/scripts/linux 2007-03-10 13:28:36.000000000 +0100 @@ -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-2005 + # Notes: @@ -19,17 +22,25 @@ # address if it is not supplied. This might be much more easily done # by the dhclient C code, and passed on. -# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious -# of the $1 in its args. +function make_resolv_conf() { + local d + local ns + + if [ -n "$DOMAIN" ]; then + d="search $DOMAIN" + elif [ -n "$new_domain_name" ]; then + d="search $new_domain_name" + fi -make_resolv_conf() { - if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then - echo search $new_domain_name >/etc/resolv.conf - chmod 644 /etc/resolv.conf + if [ -n "$new_domain_name_servers" ]; then for nameserver in $new_domain_name_servers; do - echo nameserver $nameserver >>/etc/resolv.conf + ns="$ns"$'\n'"nameserver $nameserver" done fi + + 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. @@ -53,6 +64,25 @@ 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 + release=`uname -r` release=`expr $release : '\(.*\)\..*'` relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'` @@ -106,14 +136,6 @@ 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$old_host_name ]; then - if [ x$current_hostname = x ] || \ - [ 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 @@ -136,17 +158,36 @@ ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then route add -net $new_network_number $new_subnet_arg dev $interface fi - for router in $new_routers; do - route add default gw $router - done + if [ "${PEERGATEWAY}" != "no" ]; then + for router in $new_routers; do + route add default gw $router $interface + done + fi fi - if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; - then + if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; then ifconfig $interface:0- inet 0 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 @@ -174,8 +215,7 @@ ifconfig $interface inet $new_ip_address $new_subnet_arg \ $new_broadcast_arg set $new_routers - ############## what is -w in ping? - if ping -q -c 1 $1; then + if ping -q -c 1 -w 10 $1 > /dev/null 2>&1; then if [ x$new_ip_address != x$alias_ip_address ] && \ [ x$alias_ip_address != x ]; then ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg @@ -185,10 +225,17 @@ ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then route add -net $new_network_number fi - for router in $new_routers; do - route add default gw $router - done - make_resolv_conf + if [ "${PEERGATEWAY}" != "no" ]; then + for router in $new_routers; do + route add default gw $router $interface + done + fi + if [ -n "$METRIC" ]; then + ifmetric $interface $METRIC + fi + if [ "${PEERDNS}" != "no" ]; then + make_resolv_conf + fi exit_with_hooks 0 fi ifconfig $interface inet 0 down