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