2a5c862eda753ded889baa1320fe57ceb38d0812
[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 --- a/scripts/live
9 +++ b/scripts/live
10 @@ -429,7 +429,7 @@
11                                 echo "search ${DNSDOMAIN}" >> /etc/resolv.conf
12                         fi
13  
14 -                       for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
15 +                       for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1} ${DNSSERVER1} ${DNSSERVER2}
16                         do
17                                 if [ -n "$i" ] && [ "$i" != 0.0.0.0 ]
18                                 then
19 --- a/scripts/live-bottom/23networking_grml
20 +++ b/scripts/live-bottom/23networking_grml
21 @@ -44,7 +44,12 @@
22  
23  # prepare a new /etc/network/interfaces file (and, possibly, a new /etc/resolv.conf)
24  IFFILE="/root/etc/network/interfaces"
25 -RESOLVCONF="/root/etc/resolv.conf"
26 +if [ -L /root/etc/resolv.conf ] ; then
27 +  # assume we have resolvconf
28 +  RESOLVCONF=/root/etc/resolvconf/resolv.conf.d/base
29 +else
30 +  RESOLVCONF="/root/etc/resolv.conf"
31 +fi
32  
33  # config for loopback networking
34  cat > $IFFILE << EOF
35 @@ -105,3 +110,17 @@
36  
37      echo>> $IFFILE
38  done
39 +
40 +# dns bootoption
41 +if [ -n "$DNSSERVER1" ]
42 +then
43 +       # disable any existing entries
44 +       if [ -r $RESOLVCONF ]
45 +       then
46 +               sed -i 's/nameserver/# nameserver/' $RESOLVCONF
47 +       fi
48 +       for i in $DNSSERVER1 $DNSSERVER2
49 +       do
50 +               echo "nameserver $i" >> $RESOLVCONF
51 +       done
52 +fi
53 --- a/scripts/live-helpers
54 +++ b/scripts/live-helpers
55 @@ -59,6 +59,19 @@
56                                 BOOTIF="${x#BOOTIF=}"
57                                 ;;
58  
59 +                       dns=*)
60 +                               DNSSERVER="${ARGUMENT#*=}"
61 +                               if echo "${DNSSERVER}" | grep -q , ; then
62 +                                       DNSSERVER1="${DNSSERVER%,*}"
63 +                                       DNSSERVER2="${DNSSERVER#*,}"
64 +                                       export DNSSERVER1 DNSSERVER2
65 +                               else
66 +                                       DNSSERVER1="$DNSSERVER"
67 +                                       export DNSSERVER1
68 +                               fi
69 +                               unset DNSSERVER
70 +                               ;;
71 +
72                         debug)
73                                 DEBUG="Yes"
74                                 export DEBUG