update our patches on top of Debian's 4.0~alpha19
[live-boot-grml.git] / debian / patches / 15_networking_grml.patch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 15_networking_grml.dpatch by Christian Hofstaedtler <ch@grml.org>
3 ## Licensed under GPLv2+.
4 ##
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.
8
9 @DPATCH@
10
11 diff a/scripts/live-bottom/23networking_grml b/scripts/live-bottom/23networking_grml
12 Index: live-boot-grml/components/9990-grml-networking.sh
13 ===================================================================
14 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
15 +++ live-boot-grml/components/9990-grml-networking.sh   2014-03-08 13:26:53.959682953 +0100
16 @@ -0,0 +1,93 @@
17 +#!/bin/sh
18 +
19 +#set -e
20 +
21 +Grml_Networking () {
22 +
23 +if [ -n "${NONETWORKING}" ]; then
24 +   return 0
25 +fi
26 +
27 +modprobe af_packet # req'd for DHCP
28 +
29 +# initialize udev
30 +# (this /might/ be required for firmware loading to complete)
31 +if grep -q noudev /proc/cmdline; then
32 +   log_begin_msg "Networking: Skipping udev as requested via bootoption noudev."
33 +else
34 +   udevadm trigger
35 +   udevadm settle
36 +fi
37 +
38 +if [ -n "${IP}" ]; then
39 +   # call into initramfs-tools provided network setup functions, so basic
40 +   # networking is fine.
41 +   log_begin_msg "Networking: Waiting for basic network to come up..."
42 +   configure_networking
43 +fi
44 +
45 +# prepare a new /etc/network/interfaces file (and, possibly, a new /etc/resolv.conf)
46 +IFFILE="/root/etc/network/interfaces"
47 +RESOLVCONF="/root/etc/resolv.conf"
48 +
49 +# config for loopback networking
50 +cat > $IFFILE << EOF
51 +# Initially generated on boot by initramfs' 23networking.
52 +
53 +auto lo
54 +iface lo inet loopback
55 +
56 +EOF
57 +
58 +unset HOSTNAME
59 +
60 +# generate config for each present network device
61 +for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*; do
62 +    [ -e ${interface} ] || continue
63 +    interface=$(basename ${interface})
64 +    method="dhcp"
65 +
66 +    # NODHCP or a previously run ipconfig mean that ifupdown should never
67 +    # touch this interface (IP-stack wise).
68 +    netconfig=/run/net-${interface}.conf
69 +    if [ -n "$NODHCP" ] || [ -e "${netconfig}" ]; then
70 +        method="manual"
71 +    fi
72 +
73 +    cat >> $IFFILE << EOF
74 +allow-hotplug ${interface}
75 +iface ${interface} inet ${method}
76 +EOF
77 +
78 +    # DNS for resolvconf and /etc/resolv.conf
79 +    if [ -e "${netconfig}" ]; then
80 +        . "${netconfig}"
81 +        if [ -n "${DNSDOMAIN}" ]; then
82 +            echo "    dns-search ${DNSDOMAIN}" >> $IFFILE
83 +        fi
84 +        # make sure we don't have any 0.0.0.0 nameservers
85 +        IPV4DNSLIST=""
86 +        for IPV4DNS in ${IPV4DNS0} ${IPV4DNS1}; do
87 +            [ -n "${IPV4DNS}" ] || continue
88 +            [ "${IPV4DNS}" != "0.0.0.0" ] || continue
89 +            IPV4DNSLIST="${IPV4DNSLIST}${IPV4DNS} "
90 +        done
91 +        if [ -n "${IPV4DNSLIST}" ]; then
92 +            echo "    dns-nameservers ${IPV4DNSLIST}" >> $IFFILE
93 +            for IPV4DNS in ${IPV4DNSLIST}; do
94 +                echo "nameserver ${IPV4DNS}" >> $RESOLVCONF
95 +            done
96 +        fi
97 +    fi
98 +
99 +    if [ -z "$NODHCPHOSTNAME" -a -n "$HOSTNAME" ]; then
100 +        echo $HOSTNAME > /root/etc/hostname
101 +    fi
102 +
103 +    unset DEVICE IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1 HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH filename
104 +    unset IPV4DNS IPV4DNSLIST
105 +
106 +    echo>> $IFFILE
107 +done
108 +
109 +}
110 Index: live-boot-grml/components/9990-main.sh
111 ===================================================================
112 --- live-boot-grml.orig/components/9990-main.sh 2014-03-08 13:26:53.963682483 +0100
113 +++ live-boot-grml/components/9990-main.sh      2014-03-08 13:26:53.959682953 +0100
114 @@ -195,6 +195,8 @@
115  
116         Swap
117  
118 +       Grml_Networking
119 +
120         case "${UNIONFS}" in
121                 unionfs-fuse)
122                         umount "${rootmnt}/dev"