aad51f1418b3c32cd6f766f9f1e92b61ca53328b
[live-boot-grml.git] / debian / patches / 26_support_dns_bootoption.patch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 26_support_dns_bootoption.dpatch by Michael Prokop <mika@grml.org>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Support dns bootoption. Usage examples: dns=8.8.8.8 / dns=8.8.8.8,1.2.3.4
6
7 @DPATCH@
8 Index: live-boot-grml/scripts/boot/9990-networking.sh
9 ===================================================================
10 --- live-boot-grml.orig/scripts/boot/9990-networking.sh 2013-08-15 08:01:43.007980354 +0200
11 +++ live-boot-grml/scripts/boot/9990-networking.sh      2013-08-15 08:01:43.007980354 +0200
12 @@ -152,7 +152,7 @@
13                                 echo "search ${DNSDOMAIN}" >> /etc/resolv.conf
14                         fi
15  
16 -                       for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
17 +                       for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1} ${DNSSERVER1} ${DNSSERVER2}
18                         do
19                                 if [ -n "$i" ] && [ "$i" != 0.0.0.0 ]
20                                 then
21 Index: live-boot-grml/scripts/boot/9990-grml-networking.sh
22 ===================================================================
23 --- live-boot-grml.orig/scripts/boot/9990-grml-networking.sh    2013-08-15 08:01:43.007980354 +0200
24 +++ live-boot-grml/scripts/boot/9990-grml-networking.sh 2013-08-15 08:01:43.007980354 +0200
25 @@ -28,7 +28,12 @@
26  
27  # prepare a new /etc/network/interfaces file (and, possibly, a new /etc/resolv.conf)
28  IFFILE="/root/etc/network/interfaces"
29 -RESOLVCONF="/root/etc/resolv.conf"
30 +if [ -L /root/etc/resolv.conf ] ; then
31 +  # assume we have resolvconf
32 +  RESOLVCONF=/root/etc/resolvconf/resolv.conf.d/base
33 +else
34 +  RESOLVCONF="/root/etc/resolv.conf"
35 +fi
36  
37  # config for loopback networking
38  cat > $IFFILE << EOF
39 @@ -90,4 +95,18 @@
40      echo>> $IFFILE
41  done
42  
43 +# dns bootoption
44 +if [ -n "$DNSSERVER1" ]
45 +then
46 +       # disable any existing entries
47 +       if [ -r $RESOLVCONF ]
48 +       then
49 +               sed -i 's/nameserver/# nameserver/' $RESOLVCONF
50 +       fi
51 +       for i in $DNSSERVER1 $DNSSERVER2
52 +       do
53 +               echo "nameserver $i" >> $RESOLVCONF
54 +       done
55 +fi
56 +
57  }
58 Index: live-boot-grml/scripts/boot/9990-cmdline-old
59 ===================================================================
60 --- live-boot-grml.orig/scripts/boot/9990-cmdline-old   2013-08-15 08:01:43.007980354 +0200
61 +++ live-boot-grml/scripts/boot/9990-cmdline-old        2013-08-15 08:01:43.007980354 +0200
62 @@ -18,6 +18,19 @@
63                                 BOOTIF="${_PARAMETER#BOOTIF=}"
64                                 ;;
65  
66 +                       dns=*)
67 +                               DNSSERVER="${_PARAMETER#*=}"
68 +                               if echo "${DNSSERVER}" | grep -q , ; then
69 +                                       DNSSERVER1="${DNSSERVER%,*}"
70 +                                       DNSSERVER2="${DNSSERVER#*,}"
71 +                                       export DNSSERVER1 DNSSERVER2
72 +                               else
73 +                                       DNSSERVER1="$DNSSERVER"
74 +                                       export DNSSERVER1
75 +                               fi
76 +                               unset DNSSERVER
77 +                               ;;
78 +
79                         bootid=*)
80                                 BOOTID="${_PARAMETER#bootid=}"
81                                 export BOOTID