dhcp/dhcp-4.2.2-ifup.patch
2013-07-31 23:22:01 +04:00

185 lines
5.6 KiB
Diff

diff -Naur -x '*~' -x '*.orig' -x '*.rej' dhcp-4.2.2/client/scripts/linux dhcp-4.2.2-ifup/client/scripts/linux
--- dhcp-4.2.2/client/scripts/linux 2011-05-18 22:01:54.000000000 +0200
+++ dhcp-4.2.2-ifup/client/scripts/linux 2011-08-29 19:07:58.722894019 +0200
@@ -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,28 +29,35 @@
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
shopt -s nocasematch
for nameserver in ${new_dhcp6_name_servers} ; do
@@ -59,11 +69,13 @@
else
zone_id=
fi
- echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
+ ns="$ns"$'\n'"nameserver ${nameserver}$zone_id"
done
shopt -u nocasematch
+ fi
- mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
+ if [ -n "$d" -o -n "$ns" ]; then
+ change_resolv_conf "$d" "$ns"
fi
}
@@ -88,6 +100,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
+
###
### DHCPv4 Handlers
###
@@ -138,15 +169,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(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
@@ -165,12 +187,14 @@
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
else
# we haven't changed the address, have we changed other options
# that we wish to update?
@@ -193,7 +217,25 @@
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
@@ -227,13 +269,17 @@
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