X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fgrml%2Fpump-scripts.d%2Fset-hostname;fp=etc%2Fgrml%2Fpump-scripts.d%2Fset-hostname;h=9c2c51857db070941d6a5e6312c89c3ab9c3b55a;hb=91d88e67c7e46049809a9b79b6aa7841ecda3c7d;hp=0000000000000000000000000000000000000000;hpb=98b0e91f4ac3801dd6d084f39e7c112e211e0a40;p=grml-autoconfig.git diff --git a/etc/grml/pump-scripts.d/set-hostname b/etc/grml/pump-scripts.d/set-hostname new file mode 100755 index 0000000..9c2c518 --- /dev/null +++ b/etc/grml/pump-scripts.d/set-hostname @@ -0,0 +1,24 @@ +#!/bin/zsh -e +# 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 + +. /etc/grml/autoconfig.functions + + +# only run if no nodhcphostname parameter is given +if ! checkbootparam 'nodhcphostname' ; then + + hostname=$(host $3) || exit 1 + # dhcphostname is set, get the PTR for the ip + hostname=$(echo ${hostname} | awk '{ print substr($5, 0, length($5)-1) }') + + if [ -n "$hostname" ] ; then + echo $hostname > /etc/hostname + hostname -F /etc/hostname + fi +fi