Fix to update OS version properly

This commit is contained in:
Ilia Rostovtsev
2020-11-06 18:54:27 +03:00
parent c9f4968bcb
commit 3e8418eed2
2 changed files with 14 additions and 21 deletions

View File

@@ -88,13 +88,11 @@ if (defined(&proc::get_cpu_io_usage)) {
}
}
# Remove and regenerate OS cache
# Regenerate OS cache
if ($manual) {
if (&foreign_available('webmin')) {
&unlink_file("$var_directory/modules/webmin/oscache");
&foreign_require("webmin");
my %osinfo = &webmin::detect_operating_system();
&webmin::apply_new_os_version(\%osinfo);
&webmin::detect_operating_system();
}
}

View File

@@ -1079,10 +1079,13 @@ if ($cache) {
# Check the cache file, and only re-check the OS if older than
# 1 day, or if we have rebooted recently
my %cache;
my $uptime = &get_system_uptime();
my $lastreboot = $uptime ? time()-$uptime : undef;
if (&read_file($detect_operating_system_cache, \%cache) &&
$cache{'os_type'} && $cache{'os_version'} &&
$cache{'real_os_type'} && $cache{'real_os_version'}) {
if ($cache{'time'} > time()-24*60*60) {
if ($cache{'time'} > time()-24*60*60 &&
$cache{'time'} > $lastreboot) {
return %cache;
}
}
@@ -1134,22 +1137,14 @@ if (($realos{'os_version'} ne $gconfig{'os_version'} ||
$realos{'os_type'} ne $gconfig{'os_type'}) &&
$realos{'os_version'} && $realos{'os_type'} &&
&foreign_available("webmin")) {
my ($realminor) = split(/\./, $realos{'os_version'});
my ($minor) = split(/\./, $gconfig{'os_version'});
if ($realos{'os_type'} eq $gconfig{'os_type'} &&
$realminor == $minor) {
# Only the minor version number changed - just apply silently
&apply_new_os_version(\%realos);
}
else {
# Large enough change to tell the user
push(@notifs,
&ui_form_start("$gconfig{'webprefix'}/webmin/fix_os.cgi").
&text('os_incorrect', $realos{'real_os_type'},
$realos{'real_os_version'})."<p>\n".
&ui_form_end([ [ undef, $text{'os_fix'} ] ])
);
}
# Tell the user that OS version was updated
push(@notifs,
&ui_form_start("$gconfig{'webprefix'}/webmin/fix_os.cgi").
&text('os_incorrect', $realos{'real_os_type'},
$realos{'real_os_version'})."<p>\n".
&ui_form_end([ [ undef, $text{'os_fix'} ] ])
);
}
# Password close to expiry