We solved it by putting "hostname $new_host_name" into a file at /etc/dhcp3/dhclient-exit-hooks.d/
Thanks Thomas for the tip.
default host-name "NO-NETWORK" did not work, when network was not available hostname was "none" (or blank, i'm not sure) as jason said. Booting the machine took ages, so we fleed to other solutions.
Maybe as a fix, for this bug, a sethostname script can be included in dhclient-exit-hooks.d. It can be disabled by default like the debug script there.
Be aware that, we had problems with default ubuntu installation(and loads of packages we install afterwards). "smart" NetworkManager made DCHP client ask for leases "after" gdm started, so no-X-running condition was not satisfied at that stage. We solved this by populating /etc/network/interfaces as usual. The default had only loopback interface there.
Here is a script, checks for only a running gdm though. $new_host_name is set by dhclient before calling this;
=== /etc/dhcp3/dhclient-exit-hooks.d/sethostname ======================
# This script sets the machine hostname to the hostname sent from the DHCP server.
# Beware, if this happens while X is running, there will be problems, so the script checks
# for a running gdm and does not change the hostname if it detects one.
# If you want to enable this script, change SETHOSTNAME to "yes"
SETHOSTNAME="yes"
if [ "$SETHOSTNAME" = "yes" ]; then
if test -r /var/run/gdm.pid && ps -ef | grep $(cat /var/run/gdm.pid) | grep -q /usr/sbin/gdm ; then echo "$(date): GDM running, not changing host name" >> /tmp/dhcp-sethostname.err ;
else hostname $new_host_name;
fi
fi
We solved it by putting "hostname $new_host_name" into a file at /etc/dhcp3/ dhclient- exit-hooks. d/
Thanks Thomas for the tip.
default host-name "NO-NETWORK" did not work, when network was not available hostname was "none" (or blank, i'm not sure) as jason said. Booting the machine took ages, so we fleed to other solutions.
Maybe as a fix, for this bug, a sethostname script can be included in dhclient- exit-hooks. d. It can be disabled by default like the debug script there.
Be aware that, we had problems with default ubuntu installation(and loads of packages we install afterwards). "smart" NetworkManager made DCHP client ask for leases "after" gdm started, so no-X-running condition was not satisfied at that stage. We solved this by populating /etc/network/ interfaces as usual. The default had only loopback interface there.
Here is a script, checks for only a running gdm though. $new_host_name is set by dhclient before calling this;
=== /etc/dhcp3/ dhclient- exit-hooks. d/sethostname ======= ======= ======= =
# This script sets the machine hostname to the hostname sent from the DHCP server.
# Beware, if this happens while X is running, there will be problems, so the script checks
# for a running gdm and does not change the hostname if it detects one.
# If you want to enable this script, change SETHOSTNAME to "yes"
SETHOSTNAME="yes"
if [ "$SETHOSTNAME" = "yes" ]; then
echo "$(date): GDM running, not changing host name" >> /tmp/dhcp- sethostname. err ;
hostname $new_host_name;
if test -r /var/run/gdm.pid && ps -ef | grep $(cat /var/run/gdm.pid) | grep -q /usr/sbin/gdm ; then
else
fi
fi