root / snf-deploy / files / etc / dhcp / dhclient-exit-hooks.d / hostname @ ad76b118
History | View | Annotate | Download (892 Bytes)
1 |
#!/bin/sh |
---|---|
2 |
|
3 |
# Filename: /etc/dhcp3/dhclient-exit-hooks.d/hostname |
4 |
# Purpose: Used by dhclient-script to set the hostname of the system |
5 |
# to match the DNS information for the host as provided by |
6 |
# DHCP. |
7 |
# Depends: dhcp3-client (should be in the base install) |
8 |
# hostname (for hostname, again, should be in the base) |
9 |
# bind9-host (for host) |
10 |
# coreutils (for cut and echo) |
11 |
# |
12 |
|
13 |
if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \ |
14 |
&& [ "$reason" != REBIND ] && [ "$reason" != REBOOT ] |
15 |
then |
16 |
return |
17 |
fi |
18 |
|
19 |
echo dhclient-exit-hooks.d/hostname: Dynamic IP address = $new_ip_address |
20 |
|
21 |
hostname=$(host $new_ip_address | sed 's/.$//' | cut -d ' ' -f 5) |
22 |
|
23 |
echo $hostname > /etc/hostname |
24 |
|
25 |
hostname $hostname |
26 |
|
27 |
echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = $hostname |
28 |
|
29 |
# And that _should_ just about do it... |
30 |
|