1 |
diff -p -up dhcp-4.1.1/client/scripts/linux.ifup dhcp-4.1.1/client/scripts/linux |
2 |
--- dhcp-4.1.1/client/scripts/linux.ifup 2009-04-21 11:21:09.000000000 -0300 |
3 |
+++ dhcp-4.1.1/client/scripts/linux 2010-02-25 11:26:32.000000000 -0300 |
4 |
@@ -1,8 +1,11 @@ |
5 |
#!/bin/bash |
6 |
-# dhclient-script for Linux. Dan Halbert, March, 1997. |
7 |
-# Updated for Linux 2.[12] by Brian J. Murrell, January 1999. |
8 |
-# No guarantees about this. I'm a novice at the details of Linux |
9 |
-# networking. |
10 |
+# Network Interface Configuration System |
11 |
+# |
12 |
+# Based on: |
13 |
+# dhclient-script for Linux. Dan Halbert, March, 1997. |
14 |
+# Updated for Linux 2.[12] by Brian J. Murrell, January 1999. |
15 |
+# Modified for Mandriva Linux 1999-2009 |
16 |
+ |
17 |
|
18 |
# Notes: |
19 |
|
20 |
@@ -26,35 +29,46 @@ |
21 |
ip=/sbin/ip |
22 |
|
23 |
make_resolv_conf() { |
24 |
+ local d |
25 |
+ local ns |
26 |
+ |
27 |
+ if [ -n "$DOMAIN" ]; then |
28 |
+ d="search $DOMAIN" |
29 |
+ fi |
30 |
+ |
31 |
if [ x"$new_domain_name_servers" != x ]; then |
32 |
- cat /dev/null > /etc/resolv.conf.dhclient |
33 |
- chmod 644 /etc/resolv.conf.dhclient |
34 |
- if [ x"$new_domain_search" != x ]; then |
35 |
- echo search $new_domain_search >> /etc/resolv.conf.dhclient |
36 |
+ if [ -n "$DOMAIN" ]; then |
37 |
+ # already done above |
38 |
+ d="search $DOMAIN" |
39 |
+ elif [ x"$new_domain_search" != x ]; then |
40 |
+ d="search $new_domain_search" |
41 |
elif [ x"$new_domain_name" != x ]; then |
42 |
# Note that the DHCP 'Domain Name Option' is really just a domain |
43 |
# name, and that this practice of using the domain name option as |
44 |
# a search path is both nonstandard and deprecated. |
45 |
- echo search $new_domain_name >> /etc/resolv.conf.dhclient |
46 |
+ d="search $new_domain_name" |
47 |
fi |
48 |
for nameserver in $new_domain_name_servers; do |
49 |
- echo nameserver $nameserver >>/etc/resolv.conf.dhclient |
50 |
+ ns="$ns"$'\n'"nameserver ${nameserver}" |
51 |
done |
52 |
|
53 |
- mv /etc/resolv.conf.dhclient /etc/resolv.conf |
54 |
elif [ "x${new_dhcp6_name_servers}" != x ] ; then |
55 |
- cat /dev/null > /etc/resolv.conf.dhclient6 |
56 |
- chmod 644 /etc/resolv.conf.dhclient6 |
57 |
|
58 |
- if [ "x${new_dhcp6_domain_search}" != x ] ; then |
59 |
- echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 |
60 |
+ if [ -n "$DOMAIN" ]; then |
61 |
+ # already done above |
62 |
+ d="search $DOMAIN" |
63 |
+ elif [ "x${new_dhcp6_domain_search}" != x ] ; then |
64 |
+ d="search ${new_dhcp6_domain_search}" |
65 |
fi |
66 |
for nameserver in ${new_dhcp6_name_servers} ; do |
67 |
- echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 |
68 |
+ ns="$ns"$'\n'"nameserver ${nameserver}" |
69 |
done |
70 |
+ fi |
71 |
|
72 |
- mv /etc/resolv.conf.dhclient6 /etc/resolv.conf |
73 |
+ if [ -n "$d" -o -n "$ns" ]; then |
74 |
+ change_resolv_conf "$d" "$ns" |
75 |
fi |
76 |
+ |
77 |
} |
78 |
|
79 |
# Must be used on exit. Invokes the local dhcp client exit hooks, if any. |
80 |
@@ -78,6 +92,25 @@ if [ -f /etc/dhclient-enter-hooks ]; the |
81 |
fi |
82 |
fi |
83 |
|
84 |
+# Import Mandriva Linux configuration |
85 |
+cd /etc/sysconfig/network-scripts; |
86 |
+. /etc/sysconfig/network-scripts/network-functions |
87 |
+. /etc/rc.d/init.d/functions |
88 |
+ |
89 |
+[ -f ../network ] && . ../network |
90 |
+[ -f ../networking/network ] && . ../networking/network |
91 |
+ |
92 |
+CONFIG=$interface |
93 |
+ |
94 |
+need_config ${CONFIG} |
95 |
+ |
96 |
+if [ -f "${CONFIG}" ]; then |
97 |
+ source_config |
98 |
+else |
99 |
+ echo $"$0: configuration for $interface not found." >&2 |
100 |
+ DEVICE=$interface |
101 |
+fi |
102 |
+ |
103 |
### |
104 |
### DHCPv4 Handlers |
105 |
### |
106 |
@@ -128,15 +161,6 @@ fi |
107 |
|
108 |
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ |
109 |
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then |
110 |
- current_hostname=`hostname` |
111 |
- if [ x$current_hostname = x ] || \ |
112 |
- [ x$current_hostname = "x(none)" ] || \ |
113 |
- [ x$current_hostname = xlocalhost ] || \ |
114 |
- [ x$current_hostname = x$old_host_name ]; then |
115 |
- if [ x$new_host_name != x$old_host_name ]; then |
116 |
- hostname "$new_host_name" |
117 |
- fi |
118 |
- fi |
119 |
|
120 |
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ |
121 |
[ x$alias_ip_address != x$old_ip_address ]; then |
122 |
@@ -155,12 +179,14 @@ if [ x$reason = xBOUND ] || [ x$reason = |
123 |
ifconfig $interface inet $new_ip_address $new_subnet_arg \ |
124 |
$new_broadcast_arg $mtu_arg |
125 |
# Add a network route to the computed network address. |
126 |
+ if [ "${PEERGATEWAY}" != "no" ]; then |
127 |
for router in $new_routers; do |
128 |
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
129 |
route add -host $router dev $interface |
130 |
fi |
131 |
route add default gw $router $metric_arg dev $interface |
132 |
done |
133 |
+ fi |
134 |
fi |
135 |
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; |
136 |
then |
137 |
@@ -168,7 +194,25 @@ if [ x$reason = xBOUND ] || [ x$reason = |
138 |
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg |
139 |
route add -host $alias_ip_address $interface:0 |
140 |
fi |
141 |
- make_resolv_conf |
142 |
+ if [ -n "$METRIC" ]; then |
143 |
+ ifmetric $interface $METRIC |
144 |
+ fi |
145 |
+ if [ "${PEERDNS}" != "no" ]; then |
146 |
+ make_resolv_conf |
147 |
+ fi |
148 |
+ if [ "${NEEDHOSTNAME}" = "yes" ]; then |
149 |
+ if [ -z "$new_host_name" ]; then |
150 |
+ eval `/bin/ipcalc --silent --hostname $new_ip_address` |
151 |
+ new_host_name=$HOSTNAME |
152 |
+ fi |
153 |
+ if [ -n "$new_host_name" ]; then |
154 |
+ current_hostname=`hostname` |
155 |
+ |
156 |
+ if [ "$new_host_name" != "$current_hostname" ]; then |
157 |
+ set_hostname $new_host_name |
158 |
+ fi |
159 |
+ fi |
160 |
+ fi |
161 |
exit_with_hooks 0 |
162 |
fi |
163 |
|
164 |
@@ -202,13 +246,17 @@ if [ x$reason = xTIMEOUT ]; then |
165 |
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg |
166 |
route add -host $alias_ip_address dev $interface:0 |
167 |
fi |
168 |
+ if [ "${PEERGATEWAY}" != "no" ]; then |
169 |
for router in $new_routers; do |
170 |
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
171 |
route add -host $router dev $interface |
172 |
fi |
173 |
route add default gw $router $metric_arg dev $interface |
174 |
done |
175 |
+ fi |
176 |
+ if [ "${PEERDNS}" != "no" ]; then |
177 |
make_resolv_conf |
178 |
+ fi |
179 |
exit_with_hooks 0 |
180 |
fi |
181 |
ifconfig $interface inet 0 down |