Commit 2dbc0cac authored by David G Andersen's avatar David G Andersen

A fully backwards compatable change to move DHCP name resolution

from the burned-on-CD register.pl script into the downloaded
netbed-setup.pl script.  Doesn't actually change anything, but
a CD burned with the new register.pl and intended for DHCP could
be fixed by a revised netbed-setup without requiring a new CD.

This is a transition commit to fix some minor brokenness and
inflexibility before I really revamp things to enable DHCP support,
which may require a v5 CD instead of incremental changes to the v4 CD.
We'll see...
parent 2a8627da
......@@ -157,6 +157,22 @@ else {
fatal("Tainted hostname $hostname!");
}
#
# If our IP came via DHCP, we need to figure out what it is.
#
if ($IP eq "DHCP") {
my @ipaddrs;
if ($hostname) {
(undef, undef, undef, undef, @ipaddrs) = gethostbyname($hostname);
}
if (scalar @ipaddrs) {
$IP = inet_ntoa($ipaddrs[0]);
}
else {
fatal("Invalid hostname: $hostname");
}
}
if ($IP =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) {
$IP = $1;
}
......
......@@ -99,22 +99,6 @@ if (! -s $cdkeyfile) {
$cdkey = `cat $cdkeyfile`;
chomp($cdkey);
#
# If our IP came via DHCP, we need to figure out what it is.
#
if ($IP eq "DHCP") {
my $hostname = `hostname`;
if ($hostname =~ /^([-\w\.]+)$/) {
$hostname = $1;
my (undef,undef,undef,undef,@ipaddrs) = gethostbyname($hostname);
$IP = inet_ntoa($ipaddrs[0]);
}
else {
fatal("Invalid hostname: $hostname");
}
}
#
# Get the script from netbed central. We have to be able to get it,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment