Always read hostname from config files

This commit is contained in:
Jamie Cameron
2009-05-04 19:02:40 +00:00
parent 3d57f11184
commit d12c69eee6
14 changed files with 67 additions and 3 deletions

View File

@@ -48,3 +48,4 @@ When changing the hostname on Debian or Ubuntu, update /etc/mailname too.
Fixed editing of bonding network interfaces on Debian Linux.
---- Changes since 1.480 ----
Fixed network interface management on SuSE 10.2.
Updated the Hostname and DNS Client page to always show the hostname from config files, rather than the system's short hostname.

View File

@@ -350,6 +350,11 @@ return &check_ipaddress_any($_[0]);
# get_hostname()
sub get_hostname
{
local $hn = &read_file_contents("/etc/hostname");
$hn =~ s/\r|\n//g;
if ($hn) {
return $hn;
}
return &get_system_hostname(1);
}

View File

@@ -452,6 +452,10 @@ else {
# get_hostname()
sub get_hostname
{
local %rc = &get_rc_conf();
if ($rc{'hostname'}) {
return $rc{'hostname'};
}
return &get_system_hostname();
}

View File

@@ -261,6 +261,11 @@ return &check_ipaddress($_[0]);
# get_hostname()
sub get_hostname
{
local %host;
&read_env_file("/etc/conf.d/hostname", \%host);
if ($host{'HOSTNAME'}) {
return $host{'HOSTNAME'};
}
return &get_system_hostname(1);
}

View File

@@ -370,6 +370,10 @@ return undef;
# get_hostname()
sub get_hostname
{
local $hc = &read_hostconfig();
if ($hc->{'HOSTNAME'}) {
return $hc->{'HOSTNAME'};
}
return &get_system_hostname();
}

View File

@@ -105,6 +105,11 @@ return &check_ipaddress($_[0]);
sub get_hostname
{
local %conf;
&read_env_file($network_config, \%conf);
if ($conf{'HOSTNAME'}) {
return $conf{'HOSTNAME'};
}
return &get_system_hostname(1);
}

View File

@@ -389,9 +389,14 @@ sub parse_order
# get_hostname()
sub get_hostname
{
return &get_system_hostname();
}
{
local $hn = &read_file_contents("/etc/myname");
$hn =~ s/\r|\n//g;
if ($hn) {
return $hn;
}
return &get_system_hostname();
}
# save_hostname(name)
sub save_hostname

View File

@@ -205,6 +205,11 @@ return &check_ipaddress($_[0]);
# get_hostname()
sub get_hostname
{
local %conf;
&read_env_file($network_config, \%conf);
if ($conf{'HOSTNAME'}) {
return $conf{'HOSTNAME'};
}
return &get_system_hostname(1);
}

View File

@@ -254,6 +254,11 @@ return &check_ipaddress($_[0]);
# get_hostname()
sub get_hostname
{
local $hn = &read_file_contents("/etc/HOSTNAME");
$hn =~ s/\r|\n//g;
if ($hn) {
return $hn;
}
return &get_system_hostname(1);
}

View File

@@ -216,6 +216,11 @@ return &check_ipaddress($_[0]);
# get_hostname()
sub get_hostname
{
local $hn = &read_file_contents("/etc/HOSTNAME");
$hn =~ s/\r|\n//g;
if ($hn) {
return $hn;
}
return &get_system_hostname(1);
}

View File

@@ -296,6 +296,11 @@ else {
# get_hostname()
sub get_hostname
{
local $hn = &read_file_contents("/etc/nodename");
$hn =~ s/\r|\n//g;
if ($hn) {
return $hn;
}
return &get_system_hostname();
}

View File

@@ -151,6 +151,11 @@ return &check_ipaddress($_[0]);
# get_hostname()
sub get_hostname
{
local $hn = &read_file_contents("/etc/HOSTNAME");
$hn =~ s/\r|\n//g;
if ($hn) {
return $hn;
}
return &get_system_hostname(1);
}

View File

@@ -237,6 +237,11 @@ return &check_ipaddress($_[0]);
# get_hostname()
sub get_hostname
{
local $hn = &read_file_contents("/etc/HOSTNAME");
$hn =~ s/\r|\n//g;
if ($hn) {
return $hn;
}
return &get_system_hostname(1);
}

View File

@@ -110,6 +110,11 @@ return &check_ipaddress($_[0]);
# get_hostname()
sub get_hostname
{
local %conf;
&read_env_file($network_config, \%conf);
if ($conf{'HOSTNAME'}) {
return $conf{'HOSTNAME'};
}
return &get_system_hostname(1);
}