summaryrefslogtreecommitdiffstats
path: root/modules-available/systemstatus/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2023-07-04 14:10:46 +0200
committerSimon Rettberg2023-07-04 14:10:46 +0200
commit13c22169624e5633977ed62b95aed844301881ac (patch)
treeff87f8ddd057070c898aa6c73f0779f094f5608b /modules-available/systemstatus/page.inc.php
parentUpdate phpStorm: Disable "accidental + instead of ." warning (diff)
downloadslx-admin-13c22169624e5633977ed62b95aed844301881ac.tar.gz
slx-admin-13c22169624e5633977ed62b95aed844301881ac.tar.xz
slx-admin-13c22169624e5633977ed62b95aed844301881ac.zip
[systemstatus] Show (estimate) of last time updates were installed
Plus other minor tweaks, like message on main page.
Diffstat (limited to 'modules-available/systemstatus/page.inc.php')
-rw-r--r--modules-available/systemstatus/page.inc.php23
1 files changed, 10 insertions, 13 deletions
diff --git a/modules-available/systemstatus/page.inc.php b/modules-available/systemstatus/page.inc.php
index 302e150d..34dbcc84 100644
--- a/modules-available/systemstatus/page.inc.php
+++ b/modules-available/systemstatus/page.inc.php
@@ -123,7 +123,7 @@ class Page_SystemStatus extends Page
protected function ajaxListUpgradable()
{
- User::assertPermission("apt.*");
+ User::assertPermission("tab.listupgradable");
if (User::hasPermission('apt.update')
&& Taskmanager::isRunning(Taskmanager::status(self::TM_UPDATE_UUID))) {
@@ -137,15 +137,9 @@ class Page_SystemStatus extends Page
$task = Taskmanager::submit('AptGetUpgradable');
// Estimate last time package list was updated
- $osRelease = parse_ini_file('/etc/os-release');
- $lastDownload = filemtime('/var/lib/apt/lists/partial');
- $lastChanged = 0;
- foreach (glob('/var/lib/apt/lists/*_dists_' . ($osRelease['VERSION_CODENAME'] ?? '') . '*_InRelease', GLOB_NOSORT) as $f) {
- $b = basename($f);
- if (preg_match('/dists_[a-z]+(?:[\-_]updates)?_InRelease$/', $b)) {
- $lastChanged = max($lastChanged, filemtime($f));
- }
- }
+ $lastPackageInstalled = SystemStatus::getDpkgLastPackageChanges();
+ $lastListDownloadAttempt = SystemStatus::getAptLastUpdateAttemptTime();
+ $updateDbTime = SystemStatus::getAptLastDbUpdateTime();
$perms = [];
Permission::addGlobalTags($perms, 0, ['apt.update', 'apt.upgrade', 'apt.autoremove', 'apt.fix']);
@@ -160,14 +154,17 @@ class Page_SystemStatus extends Page
if (!Taskmanager::isFailed($task) && empty($task['data']['packages'])) {
$task['data']['error'] = '';
}
+ } else {
+ $task['data']['error'] = 'ECONNREFUSED';
}
echo Render::parse('sys-update-main', [
'task' => $task['data'],
- 'lastDownload' => Util::prettyTime($lastDownload),
- 'lastChanged' => Util::prettyTime($lastChanged),
+ 'lastDownload' => Util::prettyTime($lastListDownloadAttempt),
+ 'lastChanged' => Util::prettyTime($updateDbTime),
+ 'lastInstalled' => Util::prettyTime($lastPackageInstalled),
'perm' => $perms,
- 'list_old' => $lastDownload + 86400 < time(),
+ 'list_old' => $lastListDownloadAttempt + 86400 < time(),
]);
}