0401075408496bf502146237d0a5ee2b65cc4a2d
[grml-autoconfig.git] / etc / grml / pump-scripts.d / set-hostname
1 #!/bin/zsh -e
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 . /etc/grml/autoconfig.functions
11
12 # only run if no nodhcphostname parameter is given
13 # and if running in live mode
14 if ! checkbootparam 'nodhcphostname' && [ -f /etc/grml_cd ] ; then
15
16     hostname=$(busybox nslookup $3 | awk '/Address 1: '$3'/ {print $4}')
17     [ -n $hostname ] || exit 1
18
19     grml-hostname $hostname
20     hostname -F /etc/hostname
21 fi