tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / dhcp / contrib / sethostname.sh
blob7088c00aa1eda9394f94d5d68d4718c15795bc4a
1 #!/bin/sh
3 # This script can be installed in /etc/dhclient-enter-hooks to set the client's
4 # hostname based either on the hostname that the DHCP server supplied or the
5 # hostname in whatever ptr record exists for the assigned IP address.
7 if [ x$new_host_name = x ]; then
8 ptrname=`echo $new_ip_address \
9 |sed -e \
10 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1.in-addr.arpa/'`
11 (echo "set type=ptr"; echo "$ptrname") |nslookup >/tmp/nslookup.$$
12 set `sed -n -e "s/$ptrname[ ]*\(canonical \)*name *= *\(.*\)/\2 \1/p" \
13 < /tmp/nslookup.$$` _
14 if [ x$1 = x_ ]; then
15 new_host_name=""
16 else
17 if [ $# -gt 1 ] && [ x$2 = xcanonical ]; then
18 new_host_name=`sed -n -e "s/$1[ ]*name *= *\(.*\)/\1/p" \
19 </tmp/nslookup.$$`
20 else
21 new_host_name=$1
24 rm /tmp/nslookup.$$
26 if [ x$new_host_name != x ]; then
27 hostname $new_host_name