Add a dhcphostname option to grml which will set the hostname of the booted system...
[grml-autoconfig.git] / etc / grml / pump-script
diff --git a/etc/grml/pump-script b/etc/grml/pump-script
new file mode 100644 (file)
index 0000000..2d0ef13
--- /dev/null
@@ -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