Skip to content

Commit

Permalink
Option to always get hostname from command
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Apr 6, 2011
1 parent c10a38c commit 9b36747
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions web-lib-funcs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3291,7 +3291,7 @@ sub foreign_defined
return defined(&$func);
}

=head2 get_system_hostname([short])
=head2 get_system_hostname([short], [skip-file])
Returns the hostname of this system. If the short parameter is set to 1,
then the domain name is not prepended - otherwise, Webmin will attempt to get
Expand All @@ -3301,11 +3301,15 @@ =head2 get_system_hostname([short])
sub get_system_hostname
{
my $m = int($_[0]);
my $skipfile = $_[1];
if (!$main::get_system_hostname[$m]) {
if ($gconfig{'os_type'} ne 'windows') {
# Try some common Linux hostname files first
my $fromfile;
if ($gconfig{'os_type'} eq 'redhat-linux') {
if ($skipfile) {
# Never get from file
}
elsif ($gconfig{'os_type'} eq 'redhat-linux') {
my %nc;
&read_env_file("/etc/sysconfig/network", \%nc);
if ($nc{'HOSTNAME'}) {
Expand Down Expand Up @@ -3334,7 +3338,7 @@ sub get_system_hostname
}
}

# If we found a hostname, use it if value
# If we found a hostname in a file, use it
if ($fromfile && ($m || $fromfile =~ /\./)) {
if ($m) {
$fromfile =~ s/\..*$//;
Expand Down

0 comments on commit 9b36747

Please sign in to comment.