Add a dhcphostname option to grml which will set the hostname of the booted system...
[grml-autoconfig.git] / etc / grml / pump-script
1 #!/bin/sh
2 # PUMP Script
3 # $1 Calling circumstance (up, renewal, down)
4 # $2 interface
5 # $3 ip
6
7 # Exit early, if we're not being called for the initial lease
8 [ "$1" != "up" ] && exit 0
9
10 # See if we're needed at all, only run when booted with dhcphostname
11 for i in $(cat /proc/cmdline)
12 do
13         if [ "$i" = "dhcphostname" ]
14         then
15                 # dhcphostname is set, get the PTR for the ip
16                 hostname=$(host $3 | awk '{ print substr($5, 0, length($5)-1) }')
17                 if [ -n "$hostname" ]
18                 then
19                         echo $hostname > /etc/hostname
20                 fi
21         fi
22 done