aboutsummaryrefslogtreecommitdiff
path: root/admin/api/getUpdates.php
diff options
context:
space:
mode:
authorMinteck <46352972+Minteck@users.noreply.github.com>2021-08-01 22:28:15 +0200
committerMinteck <46352972+Minteck@users.noreply.github.com>2021-08-01 22:28:15 +0200
commit9852b6cd074cceec0d0b549bb6c9bd7fe50c86f2 (patch)
tree22d9b851864f9370282f21d10113afd5d565e4cf /admin/api/getUpdates.php
parentb028da9fea70c65ccd52d1d478859739027d756a (diff)
downloadmain-9852b6cd074cceec0d0b549bb6c9bd7fe50c86f2.tar.gz
main-9852b6cd074cceec0d0b549bb6c9bd7fe50c86f2.tar.bz2
main-9852b6cd074cceec0d0b549bb6c9bd7fe50c86f2.zip
Update
Diffstat (limited to 'admin/api/getUpdates.php')
-rw-r--r--admin/api/getUpdates.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/admin/api/getUpdates.php b/admin/api/getUpdates.php
new file mode 100644
index 0000000..57ce275
--- /dev/null
+++ b/admin/api/getUpdates.php
@@ -0,0 +1,26 @@
+<?php
+
+header("Content-Type: application/json");
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+exec("bash -c \"sudo apt-get upgrade -s| grep ^Inst\"", $ret);
+$data = [];
+$data["count"] = count($ret);
+$data["packages"] = [];
+
+foreach ($ret as $package) {
+ $parts = explode(" ", trim($package));
+ $pkg = [
+ "name" => trim($parts[1]),
+ "version" => [
+ "local" => trim(explode("]", explode("[", $parts[2])[1])[0]),
+ "remote" => trim(explode("(", $parts[3])[1]),
+ ],
+ "repos" => trim(explode(":", explode("(", explode("[", trim($package))[1])[1])[1]),
+ "architecture" => trim(explode("]", explode("[", trim($package))[2])[0])
+ ];
+
+ $data["packages"][] = $pkg;
+}
+
+echo(json_encode($data, JSON_PRETTY_PRINT)); \ No newline at end of file