mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Fix setting hostname for Debian and Ubuntu using hostnamectl
This commit is contained in:
@@ -571,6 +571,13 @@ foreach my $f ("/etc/hostname", "/etc/HOSTNAME", "/etc/mailname") {
|
||||
&close_tempfile(HOST);
|
||||
}
|
||||
}
|
||||
|
||||
# Use the hostnamectl command as well
|
||||
if (&has_command("hostnamectl")) {
|
||||
&system_logged("hostnamectl set-hostname ".quotemeta($hostname).
|
||||
" >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
undef(@main::get_system_hostname); # clear cache
|
||||
}
|
||||
|
||||
|
||||
@@ -387,15 +387,21 @@ return &get_system_hostname();
|
||||
sub save_hostname
|
||||
{
|
||||
my ($hostname) = @_;
|
||||
my (%conf, $f);
|
||||
&system_logged("hostname ".quotemeta($hostname)." >/dev/null 2>&1");
|
||||
foreach $f ("/etc/hostname", "/etc/HOSTNAME", "/etc/mailname") {
|
||||
foreach my $f ("/etc/hostname", "/etc/HOSTNAME", "/etc/mailname") {
|
||||
if (-r $f) {
|
||||
&open_lock_tempfile(HOST, ">$f");
|
||||
&print_tempfile(HOST, $_[0],"\n");
|
||||
&print_tempfile(HOST, $hostname,"\n");
|
||||
&close_tempfile(HOST);
|
||||
}
|
||||
}
|
||||
|
||||
# Use the hostnamectl command as well
|
||||
if (&has_command("hostnamectl")) {
|
||||
&system_logged("hostnamectl set-hostname ".quotemeta($hostname).
|
||||
" >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
undef(@main::get_system_hostname); # clear cache
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user