1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 15_networking_grml.dpatch by Christian Hofstaedtler <ch@grml.org>
3 ## Licensed under GPLv2+.
5 ## All lines beginning with `## DP:' are a description of the patch.
6 ## DP: Ship our own networking script, which is compatible with the kernel's
7 ## DP: notion of ip= as well as resolvconf.
11 diff a/scripts/live-bottom/23networking_grml b/scripts/live-bottom/23networking_grml
13 +++ b/scripts/live-bottom/23networking_grml
19 +# initramfs-tools header
35 +. /scripts/live-functions
37 +if [ -n "${NONETWORKING}" ]; then
41 +modprobe af_packet # req'd for DHCP
44 +# (this /might/ be required for firmware loading to complete)
45 +if grep -q noudev /proc/cmdline; then
46 + log_begin_msg "Networking: Skipping udev as requested via bootoption noudev."
52 +if [ -n "${IP}" ]; then
53 + # call into initramfs-tools provided network setup functions, so basic
54 + # networking is fine.
55 + log_begin_msg "Networking: Waiting for basic network to come up..."
56 + configure_networking
59 +# prepare a new /etc/network/interfaces file (and, possibly, a new /etc/resolv.conf)
60 +IFFILE="/root/etc/network/interfaces"
61 +RESOLVCONF="/root/etc/resolv.conf"
63 +# config for loopback networking
65 +# Initially generated on boot by initramfs' 23networking.
68 +iface lo inet loopback
72 +# generate config for each present network device
73 +for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*; do
74 + [ -e ${interface} ] || continue
75 + interface=$(basename ${interface})
78 + # NODHCP or a previously run ipconfig mean that ifupdown should never
79 + # touch this interface (IP-stack wise).
80 + netconfig=/tmp/net-${interface}.conf
81 + if [ -n "$NODHCP" ] || [ -e "${netconfig}" ]; then
85 + cat >> $IFFILE << EOF
86 +allow-hotplug ${interface}
87 +iface ${interface} inet ${method}
90 + # DNS for resolvconf and /etc/resolv.conf
91 + if [ -e "${netconfig}" ]; then
93 + if [ -n "${DNSDOMAIN}" ]; then
94 + echo " dns-search ${DNSDOMAIN}" >> $IFFILE
96 + # make sure we don't have any 0.0.0.0 nameservers
98 + for IPV4DNS in ${IPV4DNS0} ${IPV4DNS1}; do
99 + [ -n "${IPV4DNS}" ] || continue
100 + [ "${IPV4DNS}" != "0.0.0.0" ] || continue
101 + IPV4DNSLIST="${IPV4DNSLIST}${IPV4DNS} "
103 + if [ -n "${IPV4DNSLIST}" ]; then
104 + echo " dns-nameservers ${IPV4DNSLIST}" >> $IFFILE
105 + for IPV4DNS in ${IPV4DNSLIST}; do
106 + echo "nameserver ${IPV4DNS}" >> $RESOLVCONF
110 + unset DEVICE IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1 HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH filename
111 + unset IPV4DNS IPV4DNSLIST