Add a dhcphostname option to grml which will set the hostname of the booted system according to the dns information. This Patch implements support for the non-netboot cases by adding an appropriate script to be called by pump. diffstat dhcphostname-pump.patch autoconfig.functions | 2 +- etc/grml/pump-script | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) signed-off-by: Andreas Thienemann diff --git a/autoconfig.functions b/autoconfig.functions index c1bc848..6bc1d5a 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -1264,7 +1264,7 @@ else einfo "Network device ${WHITE}${DEVICE}${NORMAL} detected, DHCP broadcasting for IP. (Backgrounding)" trap 2 3 11 ifconfig $DEVICE up >>$DEBUG 2>&1 - ( pump -i $DEVICE >>$DEBUG 2>&1 && echo finished_running_pump > /etc/network/status/$DEVICE ) & + ( pump -i $DEVICE --script=/etc/grml/pump-script >>$DEBUG 2>&1 && echo finished_running_pump > /etc/network/status/$DEVICE ) & trap "" 2 3 11 sleep 1 eend 0 diff --git a/etc/grml/pump-script b/etc/grml/pump-script new file mode 100644 index 0000000..2d0ef13 --- /dev/null +++ b/etc/grml/pump-script @@ -0,0 +1,22 @@ +#!/bin/sh +# PUMP Script +# $1 Calling circumstance (up, renewal, down) +# $2 interface +# $3 ip + +# Exit early, if we're not being called for the initial lease +[ "$1" != "up" ] && exit 0 + +# See if we're needed at all, only run when booted with dhcphostname +for i in $(cat /proc/cmdline) +do + if [ "$i" = "dhcphostname" ] + then + # dhcphostname is set, get the PTR for the ip + hostname=$(host $3 | awk '{ print substr($5, 0, length($5)-1) }') + if [ -n "$hostname" ] + then + echo $hostname > /etc/hostname + fi + fi +done