mirror of
https://github.com/webmin/webmin.git
synced 2026-05-14 10:40:29 +01:00
Add hostname detection using hostnamectl command
This commit is contained in:
@@ -4250,6 +4250,17 @@ my $m = int($_[0]);
|
||||
my $skipfile = $_[1];
|
||||
if (!$main::get_system_hostname[$m]) {
|
||||
if ($gconfig{'os_type'} ne 'windows') {
|
||||
# Try hostnamectl command on Linux
|
||||
if (&has_command("hostnamectl")) {
|
||||
my $hostname =
|
||||
&backquote_command("hostnamectl --static");
|
||||
chop($hostname);
|
||||
if ($? == 0 && $hostname =~ /\./) {
|
||||
$hostname =~ s/\..*$// if ($m);
|
||||
$main::get_system_hostname[$m] = $hostname;
|
||||
return $hostname;
|
||||
}
|
||||
}
|
||||
# Try some common Linux hostname files first
|
||||
my $fromfile;
|
||||
if ($skipfile) {
|
||||
|
||||
Reference in New Issue
Block a user