From 25572f014e8e1e547b6be8aee0c19109f71420ad Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Mon, 11 Nov 2024 18:50:13 -0800 Subject: [PATCH] Allow packages to be removed on low memory nodes. (#1684) We haven't supported installing packages on low memory node for a few years now, but we will want to provide a mechanism to remove them even with the new UI. --- files/app/main/status/e/packages.ut | 8 +++++-- files/app/partial/general.ut | 4 ---- files/app/partial/packages.ut | 33 +++++++++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/files/app/main/status/e/packages.ut b/files/app/main/status/e/packages.ut index d7470630..60b15973 100755 --- a/files/app/main/status/e/packages.ut +++ b/files/app/main/status/e/packages.ut @@ -235,6 +235,7 @@ const po = getPackageOptions(); {{_R("dialog-header", "Packages")}}
{{_R("dialog-messages")}} + {% if (!hardware.isLowMemNode()) { %}
Download Package
@@ -263,6 +264,7 @@ const po = getPackageOptions(); {{_H("Upload a package file from your computer. Once the package has been selected it can be uploaded and installed using the button at the base of the dialog.")}}

+ {% } %}
Remove Package
@@ -274,6 +276,7 @@ const po = getPackageOptions();
{{_H("Remove a currently installed package from the node by first selecting it and then using the button at the based of the dialog to remove it.")}} + {% if (!hardware.isLowMemNode()) { %} {{_R("dialog-advanced")}}
{% if (includeAdvanced) { %} @@ -290,13 +293,14 @@ const po = getPackageOptions(); to a local server, especially if you'd like to do this without a connection to the Internet.")}} {% } %}
+ {% } %}
- +
{{_H("
Depending on the package option selected above, this button will initiate the download, upload, install or remove process.")}} @@ -394,7 +398,7 @@ const po = getPackageOptions(); source: e.currentTarget, swap: "none" }).then(_ => { - htmx.find("#fetch-and-update").innerText = "Fetch and Install"; + htmx.find("#fetch-and-update").innerText = !hardware.isLowMemNode() ? "Fetch and Install" : "Remove"; htmx.find("#remove-package").value = "-"; }); } diff --git a/files/app/partial/general.ut b/files/app/partial/general.ut index c26668f6..31c22f07 100755 --- a/files/app/partial/general.ut +++ b/files/app/partial/general.ut @@ -51,10 +51,6 @@ {{_R("health")}}
{{_R("firmware")}} -{% if (auth.isAdmin && !hardware.isLowMemNode()) { %} -
{{_R("packages")}} -
-{% } %}
{{_R("network")}} diff --git a/files/app/partial/packages.ut b/files/app/partial/packages.ut index 5e2eaefb..65c99c27 100755 --- a/files/app/partial/packages.ut +++ b/files/app/partial/packages.ut @@ -33,21 +33,26 @@ */ %} {% -let count = 0; -if (!fs.access("/etc/cron.boot/reinstall-packages")) { - const opkgs = {}; - map(split(fs.readfile("/etc/permpkg"), "\n"), p => opkgs[p] = true); - const f = fs.popen("/bin/opkg list-installed"); - if (f) { - for (let l = f.read("line"); length(l); l = f.read("line")) { - const m = match(l, /^[^ \t]+/); - if (m && !opkgs[m[0]]) { - count++; +if (auth.isAdmin) { + let count = 0; + if (!fs.access("/etc/cron.boot/reinstall-packages")) { + const opkgs = {}; + map(split(fs.readfile("/etc/permpkg"), "\n"), p => opkgs[p] = true); + const f = fs.popen("/bin/opkg list-installed"); + if (f) { + for (let l = f.read("line"); length(l); l = f.read("line")) { + const m = match(l, /^[^ \t]+/); + if (m && !opkgs[m[0]]) { + count++; + } } + f.close(); } - f.close(); } -} + if (count > 0 || !hardware.isLowMemNode()) { %} -
{{count}}
-
installed packages
+
+
{{count}}
+
installed packages
+
+{% } } %}