X-Git-Url: http://git.grml.org/?p=grml-autoconfig.git;a=blobdiff_plain;f=etc%2Fdhcp3%2Fdhclient-exit-hooks.d%2Fgrml-sethostname;fp=etc%2Fdhcp3%2Fdhclient-exit-hooks.d%2Fgrml-sethostname;h=acd03a2913672183e05664a82dd5a03c2dc239c2;hp=0000000000000000000000000000000000000000;hb=8147fe1009e24e218bf20b9f6c1b94fd9465ffda;hpb=efc764b66b6954e7cb138414f4cc12bd9c7201f2 diff --git a/etc/dhcp3/dhclient-exit-hooks.d/grml-sethostname b/etc/dhcp3/dhclient-exit-hooks.d/grml-sethostname new file mode 100755 index 0000000..acd03a2 --- /dev/null +++ b/etc/dhcp3/dhclient-exit-hooks.d/grml-sethostname @@ -0,0 +1,12 @@ +# only run the comamnd if we bound to a new ip +case "$reason" in BOUND) +if ! grep -q 'nodhcphostname' /proc/cmdline && [ -f /etc/grml_cd ] ; then + + hostname=$(busybox nslookup "$new_ip_address" | awk '/Address 1: '$new_ip_address'/ {print $4}') + if [ -n "$hostname" ] ; then + grml-hostname "$hostname" + hostname -F /etc/hostname + fi +fi +;; +esac