]>
git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/40network/dhclient-script.sh
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
9 bcast
=$new_broadcast_address
11 domain
=$new_domain_name
12 search
=$
(printf "$new_domain_search")
13 namesrv
=$new_domain_name_servers
14 hostname
=$new_host_name
16 [ -f /tmp
/net.
$netif.override
] && .
/tmp
/net.
$netif.override
18 # Taken from debian dhclient-script:
19 # The 576 MTU is only used for X.25 and dialup connections
20 # where the admin wants low latency. Such a low MTU can cause
21 # problems with UDP traffic, among other things. As such,
22 # disallow MTUs from 576 and below by default, so that broken
23 # MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
24 if [ -n "$mtu" ] && [ $mtu -gt 576 ] ; then
25 if ! ip link
set $netif mtu
$mtu ; then
26 ip link
set $netif down
27 ip link
set $netif mtu
$mtu
32 ip addr add
$ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev
$netif
34 [ -n "$gw" ] && echo ip route add default via
$gw dev
$netif > /tmp
/net.
$netif.gw
36 [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp
/net.
$netif.resolv.conf
37 if [ -n "$namesrv" ] ; then
41 fi >> /tmp
/net.
$netif.resolv.conf
43 # Note: hostname can be fqdn OR short hostname, so chop off any
44 # trailing domain name and explicity add any domain if set.
45 [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain+.$domain} > /proc/sys/kernel/hostname" > /tmp
/net.
$netif.hostname
48 PATH
=/usr
/sbin
:/usr
/bin
:/sbin
:/bin
50 export PS4
="dhclient.$interface.$$ + "
51 exec >>/run
/initramfs
/loginit.pipe
2>>/run
/initramfs
/loginit.pipe
52 type getarg
>/dev
/null
2>&1 || .
/lib
/dracut-lib.sh
53 type ip_to_var
>/dev
/null
2>&1 || .
/lib
/net-lib.sh
55 # We already need a set netif here
58 # Huh? Interface configured?
59 [ -f "/tmp/net.$netif.up" ] && exit 0
63 echo "dhcp: PREINIT $netif up"
67 echo "dhcp: BOND setting $netif"
69 if [ -f /sys
/class
/net
/$netif/device
/layer2
]; then
70 read layer2
< /sys
/class
/net
/$netif/device
/layer2
72 if [ "$layer2" != "0" ]; then
73 if ! arping
-q -D -c 2 -I $netif $new_ip_address ; then
74 warn
"Duplicate address detected for $new_ip_address while doing dhcp. retrying"
80 set |
while read line
; do
81 [ "${line#new_}" = "$line" ] && continue
83 done >/tmp
/dhclient.
$netif.dhcpopts
86 echo '. /lib/net-lib.sh'
87 echo "setup_net $netif"
88 echo "source_hook initqueue/online $netif"
89 [ -e /tmp
/net.
$netif.manualup
] ||
echo "/sbin/netroot $netif"
90 echo "> /tmp/setup_net_$netif.ok"
91 echo "> /tmp/setup_net_\$(cat /sys/class/net/$netif/address).ok"
92 echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
93 } > $hookdir/initqueue
/setup_net_
$netif.sh
95 echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue
/finished
/dhclient-
$netif.sh
98 *) echo "dhcp: $reason";;