diff options
author | Simon Rettberg | 2023-07-04 14:10:46 +0200 |
---|---|---|
committer | Simon Rettberg | 2023-07-04 14:10:46 +0200 |
commit | 13c22169624e5633977ed62b95aed844301881ac (patch) | |
tree | ff87f8ddd057070c898aa6c73f0779f094f5608b /modules-available/systemstatus/inc | |
parent | Update phpStorm: Disable "accidental + instead of ." warning (diff) | |
download | slx-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/inc')
-rw-r--r-- | modules-available/systemstatus/inc/systemstatus.inc.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/modules-available/systemstatus/inc/systemstatus.inc.php b/modules-available/systemstatus/inc/systemstatus.inc.php index 36b4ef36..85f0410b 100644 --- a/modules-available/systemstatus/inc/systemstatus.inc.php +++ b/modules-available/systemstatus/inc/systemstatus.inc.php @@ -57,4 +57,42 @@ class SystemStatus return true; } + /** + * Get timestamp of the available updates. This is an estimate, the downloaded apt data usually + * preserves the Last-Modified timestamp from the HTTP download or the according data. Note + * that this list gets updated whener any available package changes, so it does not necessarily + * mean that any currently installed package can be updated when the list changes. + */ + public static function getAptLastDbUpdateTime(): int + { + $osRelease = parse_ini_file('/etc/os-release'); + $updateDbTime = 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)) { + $updateDbTime = max($updateDbTime, filemtime($f)); + } + } + return $updateDbTime; + } + + /** + * Get timestamp when the apt database was last attempted to be updated. This does not + * imply that the operation was successful. + */ + public static function getAptLastUpdateAttemptTime(): int + { + return (int)filemtime('/var/lib/apt/lists/partial'); + } + + /** + * Get when the dpkg database was last changed, i.e. when a package was last installed, updated or removed. + * This is an estimate as it just looks at the modification time of relevant files. It is possible these + * files get modified for other reasons. + */ + public static function getDpkgLastPackageChanges(): int + { + return (int)filemtime(file_exists('/var/log/dpkg.log') ? '/var/log/dpkg.log' : '/var/lib/dpkg/status'); + } + }
\ No newline at end of file |