readd grml patches
[live-boot-grml.git] / debian / patches / 11_dhcphostname.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 11_dhcphostname.dpatch by Andreas Thienemann <andreas@bawue.net>
3 ## and Michael Prokop <mika@grml.org>
4 ##
5 ## All lines beginning with `## DP:' are a description of the patch.
6 ## DP: Support disabling setting hostname via DNS info
7
8 @DPATCH@
9
10 Support 'nodhcphostname' option which will disable setting the
11 hostname of the booted system according to the DNS information.
12 This patch takes care of the netboot case.
13
14 diff --git a/scripts/live-bottom/23networking b/scripts/live-bottom/23networking
15 index 9554b77..9270e9c 100755
16 --- a/scripts/live-bottom/23networking
17 +++ b/scripts/live-bottom/23networking
18 @@ -135,6 +135,19 @@ ${rc_server1}
19  EOF
20  
21                         cat /root/etc/resolv.conf >> /root/var/log/netboot.config
22 +
23 +                       if [ -z "$NODHCPHOSTNAME" ]
24 +                       then
25 +                               dhcp_address=$(cat netboot.config | awk '/address:/{print $2}')
26 +                               dhcp_hostname=$(busybox nslookup ${dhcp_address} ${rc_server0#nameserver }| awk \
27 +                                       '/Address 1: '${dhcp_address}'/{ print $4 }')
28 +
29 +                               if [ -n "$dhcp_hostname" ]
30 +                               then
31 +                                       echo $dhcp_hostname > /root/etc/hostname
32 +                               fi
33 +                               unset dhcp_address dhcp_hostname dhcp_hostname
34 +                       fi
35                 fi
36         fi
37  fi
38 --- a/scripts/live
39 +++ b/scripts/live
40 @@ -216,6 +216,11 @@ Arguments ()
41                                 export NOACCESSIBILITY
42                                 ;;
43  
44 +                       nodhcphostname)
45 +                               NODHCPHOSTNAME="Yes"
46 +                               export NODHCPHOSTNAME
47 +                               ;;
48 +
49                         nofastboot)
50                                 NOFASTBOOT="Yes"
51                                 export NOFASTBOOT
52