From 223d57a01c8034737bbd8aeeb81f2476f251109d Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 19 Apr 2011 14:07:57 +0000 Subject: setup-interfaces: add hostname to dhcp for dynamic dns --- setup-interfaces.in | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/setup-interfaces.in b/setup-interfaces.in index 1bbac29..e402742 100755 --- a/setup-interfaces.in +++ b/setup-interfaces.in @@ -126,16 +126,26 @@ done echo "type=loopback" > 000~lo.conf echo "" > interface +hostname=$(cat /etc/hostname 2>/dev/null) + for i in *.conf ; do iface=`basename $i .conf` iface=${iface#[0-9]*~} . ./$i echo "auto $iface" >> interfaces echo "iface $iface inet $type" >> interfaces - [ "$type" = "static" ] || continue - echo -e "\taddress $address" >> interfaces - echo -e "\tnetmask $netmask" >> interfaces - [ "$gateway" ] && echo -e "\tgateway $gateway" >> interfaces + case $type in + dhcp) + [ -n "$hostname" ] \ + && echo -e "\thostname $hostname" >> interfaces + ;; + static) + echo -e "\taddress $address" >> interfaces + echo -e "\tnetmask $netmask" >> interfaces + [ "$gateway" ] \ + && echo -e "\tgateway $gateway" >> interfaces + ;; + esac echo "" >> interfaces done -- cgit v1.2.3