1 |
guillomovitch |
136280 |
diff -Naur -x '*~' -x '*.orig' -x '*.rej' dhcp-4.2.2/client/scripts/linux dhcp-4.2.2-ifup/client/scripts/linux |
2 |
|
|
--- dhcp-4.2.2/client/scripts/linux 2011-05-18 22:01:54.000000000 +0200 |
3 |
|
|
+++ dhcp-4.2.2-ifup/client/scripts/linux 2011-08-29 19:07:58.722894019 +0200 |
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,28 +29,35 @@ |
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 |
|
|
shopt -s nocasematch |
67 |
|
|
for nameserver in ${new_dhcp6_name_servers} ; do |
68 |
|
|
@@ -59,11 +69,13 @@ |
69 |
|
|
else |
70 |
|
|
zone_id= |
71 |
|
|
fi |
72 |
|
|
- echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6 |
73 |
|
|
+ ns="$ns"$'\n'"nameserver ${nameserver}$zone_id" |
74 |
|
|
done |
75 |
|
|
shopt -u nocasematch |
76 |
|
|
+ fi |
77 |
|
|
|
78 |
|
|
- mv /etc/resolv.conf.dhclient6 /etc/resolv.conf |
79 |
|
|
+ if [ -n "$d" -o -n "$ns" ]; then |
80 |
|
|
+ change_resolv_conf "$d" "$ns" |
81 |
|
|
fi |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
@@ -88,6 +100,25 @@ |
85 |
|
|
fi |
86 |
|
|
fi |
87 |
|
|
|
88 |
|
|
+# Import Mandriva Linux configuration |
89 |
|
|
+cd /etc/sysconfig/network-scripts; |
90 |
|
|
+. /etc/sysconfig/network-scripts/network-functions |
91 |
|
|
+. /etc/rc.d/init.d/functions |
92 |
|
|
+ |
93 |
|
|
+[ -f ../network ] && . ../network |
94 |
|
|
+[ -f ../networking/network ] && . ../networking/network |
95 |
|
|
+ |
96 |
|
|
+CONFIG=$interface |
97 |
|
|
+ |
98 |
|
|
+need_config ${CONFIG} |
99 |
|
|
+ |
100 |
|
|
+if [ -f "${CONFIG}" ]; then |
101 |
|
|
+ source_config |
102 |
|
|
+else |
103 |
|
|
+ echo $"$0: configuration for $interface not found." >&2 |
104 |
|
|
+ DEVICE=$interface |
105 |
|
|
+fi |
106 |
|
|
+ |
107 |
|
|
### |
108 |
|
|
### DHCPv4 Handlers |
109 |
|
|
### |
110 |
|
|
@@ -138,15 +169,6 @@ |
111 |
|
|
|
112 |
|
|
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ |
113 |
|
|
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then |
114 |
|
|
- current_hostname=`hostname` |
115 |
|
|
- if [ x$current_hostname = x ] || \ |
116 |
|
|
- [ x$current_hostname = "x(none)" ] || \ |
117 |
|
|
- [ x$current_hostname = xlocalhost ] || \ |
118 |
|
|
- [ x$current_hostname = x$old_host_name ]; then |
119 |
|
|
- if [ x$new_host_name != x$old_host_name ]; then |
120 |
|
|
- hostname "$new_host_name" |
121 |
|
|
- fi |
122 |
|
|
- fi |
123 |
|
|
|
124 |
|
|
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ |
125 |
|
|
[ x$alias_ip_address != x$old_ip_address ]; then |
126 |
|
|
@@ -165,12 +187,14 @@ |
127 |
|
|
ifconfig $interface inet $new_ip_address $new_subnet_arg \ |
128 |
|
|
$new_broadcast_arg $mtu_arg |
129 |
|
|
# Add a network route to the computed network address. |
130 |
|
|
+ if [ "${PEERGATEWAY}" != "no" ]; then |
131 |
|
|
for router in $new_routers; do |
132 |
|
|
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
133 |
|
|
route add -host $router dev $interface |
134 |
|
|
fi |
135 |
|
|
route add default gw $router $metric_arg dev $interface |
136 |
|
|
done |
137 |
|
|
+ fi |
138 |
|
|
else |
139 |
|
|
# we haven't changed the address, have we changed other options |
140 |
|
|
# that we wish to update? |
141 |
|
|
@@ -193,7 +217,25 @@ |
142 |
|
|
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg |
143 |
|
|
route add -host $alias_ip_address $interface:0 |
144 |
|
|
fi |
145 |
|
|
- make_resolv_conf |
146 |
|
|
+ if [ -n "$METRIC" ]; then |
147 |
|
|
+ ifmetric $interface $METRIC |
148 |
|
|
+ fi |
149 |
|
|
+ if [ "${PEERDNS}" != "no" ]; then |
150 |
|
|
+ make_resolv_conf |
151 |
|
|
+ fi |
152 |
|
|
+ if [ "${NEEDHOSTNAME}" = "yes" ]; then |
153 |
|
|
+ if [ -z "$new_host_name" ]; then |
154 |
|
|
+ eval `/bin/ipcalc --silent --hostname $new_ip_address` |
155 |
|
|
+ new_host_name=$HOSTNAME |
156 |
|
|
+ fi |
157 |
|
|
+ if [ -n "$new_host_name" ]; then |
158 |
|
|
+ current_hostname=`hostname` |
159 |
|
|
+ |
160 |
|
|
+ if [ "$new_host_name" != "$current_hostname" ]; then |
161 |
|
|
+ set_hostname $new_host_name |
162 |
|
|
+ fi |
163 |
|
|
+ fi |
164 |
|
|
+ fi |
165 |
|
|
exit_with_hooks 0 |
166 |
|
|
fi |
167 |
|
|
|
168 |
|
|
@@ -227,13 +269,17 @@ |
169 |
|
|
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg |
170 |
|
|
route add -host $alias_ip_address dev $interface:0 |
171 |
|
|
fi |
172 |
|
|
+ if [ "${PEERGATEWAY}" != "no" ]; then |
173 |
|
|
for router in $new_routers; do |
174 |
|
|
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
175 |
|
|
route add -host $router dev $interface |
176 |
|
|
fi |
177 |
|
|
route add default gw $router $metric_arg dev $interface |
178 |
|
|
done |
179 |
|
|
+ fi |
180 |
|
|
+ if [ "${PEERDNS}" != "no" ]; then |
181 |
|
|
make_resolv_conf |
182 |
|
|
+ fi |
183 |
|
|
exit_with_hooks 0 |
184 |
|
|
fi |
185 |
|
|
ifconfig $interface inet 0 down |