Add Console client update control through the shared Debian updater
This commit is contained in:
parent
798d3f32d4
commit
cdba25924e
|
|
@ -0,0 +1,7 @@
|
|||
# Console 3.1.32 — client update control
|
||||
|
||||
- It-Screen shows installed and available native client versions, update availability, progress and errors.
|
||||
- Check and update delegates to the existing Debian updater socket; no duplicate download/install implementation.
|
||||
- Opening the tab performs a check-only request; it never installs or changes automatic updates. Status polling updates only the version panel, preserving registration form edits.
|
||||
- Authenticated API allowlists check-only/update; GET reads local updater state without external network requests.
|
||||
- Requires stage_itscreen 1.0.40 for the snapshot/check-only protocol extension. Older services report an explicit error.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# It-Screen stage 1.0.40 — Console update adapter
|
||||
|
||||
- Extend the existing updater socket with snapshot and check_only commands for Console.
|
||||
- Check-only never installs, including when automatic updates are enabled; manual update keeps the existing verified download, lock, rollback and startup checks.
|
||||
- Expose queued/running state and errors without changing client version 5.1.55 or update preferences.
|
||||
- Validation: 19 updater tests, frontend state tests and local ARM64 Console API checks.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"version": "1.0.1"
|
||||
},
|
||||
"stage_ui": {
|
||||
"version": "3.1.31"
|
||||
"version": "3.1.32"
|
||||
},
|
||||
"stage_avahi": {
|
||||
"version": "1.0.0"
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
"version": "1.0.0"
|
||||
},
|
||||
"stage_itscreen": {
|
||||
"version": "1.0.39"
|
||||
"version": "1.0.40"
|
||||
},
|
||||
"stage_reverse_tunnels": {
|
||||
"version": "1.0.2"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"schema_version": 1,
|
||||
"client_version": "5.1.55",
|
||||
"stage_version": "1.0.39",
|
||||
"stage_version": "1.0.40",
|
||||
"platform": "linux",
|
||||
"architecture": "arm64",
|
||||
"source_repository": "https://git.iomatex.com/Development/It-screenClient.git",
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class Updater:
|
|||
return {'link': FEED, 'period': PERIOD, 'installed_version': self.installed,
|
||||
'ready_version': self.ready, 'device_id': self.device_id,
|
||||
'active_update': int(self.automatic), 'state_update': self.phase,
|
||||
'progress_download': self.progress}
|
||||
'progress_download': self.progress, 'error': self.error, 'busy': self.busy or not self.pending.empty()}
|
||||
|
||||
def newer(self, data):
|
||||
if data['build_number'] != self.installed:
|
||||
|
|
@ -331,7 +331,7 @@ class Updater:
|
|||
finally:
|
||||
candidate.unlink(missing_ok=True)
|
||||
|
||||
def check(self, install=False):
|
||||
def check(self, install=False, check_only=False):
|
||||
self.busy = True
|
||||
candidate = None
|
||||
try:
|
||||
|
|
@ -346,7 +346,7 @@ class Updater:
|
|||
self.status('not_required')
|
||||
return
|
||||
self.status('ready')
|
||||
if not (install or self.automatic):
|
||||
if check_only or not (install or self.automatic):
|
||||
return
|
||||
self.status('downloading')
|
||||
candidate = self.download(data)
|
||||
|
|
@ -363,7 +363,7 @@ class Updater:
|
|||
while True:
|
||||
try:
|
||||
manual_install = self.pending.get(timeout=PERIOD)
|
||||
self.check(install=manual_install)
|
||||
self.check(install=manual_install is True, check_only=manual_install == "check_only")
|
||||
except queue.Empty:
|
||||
if self.automatic:
|
||||
self.check()
|
||||
|
|
@ -395,7 +395,11 @@ class Handler(socketserver.StreamRequestHandler):
|
|||
try:
|
||||
data = json.loads(line)
|
||||
action, key = data.get('action'), data.get('key')
|
||||
if action == 'get' and key in updater.values():
|
||||
if action == 'get' and key == 'snapshot':
|
||||
self.send('snapshot', updater.values())
|
||||
elif action == 'check_only':
|
||||
updater.request('check_only')
|
||||
elif action == 'get' and key in updater.values():
|
||||
self.send(key, updater.values()[key])
|
||||
elif action == 'set' and key == 'active_update':
|
||||
updater.set_automatic(data.get('value'))
|
||||
|
|
|
|||
|
|
@ -29,6 +29,21 @@ class TestUpdater(unittest.TestCase):
|
|||
executable(self.binary, '5.1.54')
|
||||
self.u = c.Updater(self.binary,self.root/'state',self.root/'cache')
|
||||
|
||||
def test_console_check_never_installs_even_with_automatic_enabled(self):
|
||||
self.u.automatic = True
|
||||
with patch.object(self.u, 'manifest', return_value=manifest()), patch.object(self.u, 'download') as download:
|
||||
self.u.check(check_only=True)
|
||||
download.assert_not_called()
|
||||
self.assertEqual(self.u.phase, 'ready')
|
||||
self.assertTrue(self.u.automatic)
|
||||
self.assertEqual(self.u.values()['ready_version'], 5010055)
|
||||
|
||||
def test_console_pending_request_is_busy(self):
|
||||
self.u.request('check_only')
|
||||
self.assertTrue(self.u.values()['busy'])
|
||||
self.assertEqual(self.u.pending.get_nowait(), 'check_only')
|
||||
self.assertFalse(self.u.values()['busy'])
|
||||
|
||||
def test_socket_checkbox_and_fragmented_frames(self):
|
||||
import os
|
||||
import socket
|
||||
|
|
@ -45,8 +60,10 @@ class TestUpdater(unittest.TestCase):
|
|||
client.settimeout(3);client.connect(path)
|
||||
stream=client.makefile('rwb',buffering=0)
|
||||
initial={}
|
||||
for _ in range(8):initial.update(json.loads(stream.readline()))
|
||||
for _ in range(len(self.u.values())):initial.update(json.loads(stream.readline()))
|
||||
self.assertEqual(initial['active_update'],0)
|
||||
stream.write(b'{"action":"get","key":"snapshot"}\n')
|
||||
self.assertEqual(json.loads(stream.readline())['snapshot']['installed_version'],5010054)
|
||||
stream.write(b'{"action":"set","key":"active_')
|
||||
stream.write(b'update","value":1}\n')
|
||||
self.assertEqual(json.loads(stream.readline()),{'active_update':1})
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"version": "1.0.39"
|
||||
"version": "1.0.40"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,3 +65,14 @@ never reports success. The firmware's power-cycle persistence is not asserted.
|
|||
|
||||
UI uses existing field/select/actionRow/card classes and the shared body-mounted
|
||||
confirmation dialog. No new CSS or independent modal/serial transport is added.
|
||||
|
||||
## Debian client updates (Console 3.1.32)
|
||||
|
||||
The It-Screen panel uses authenticated GET/POST `/api/itscreen/update`.
|
||||
`client_update_request` only adapts the existing `/tmp/itsupdater` socket;
|
||||
`stage_itscreen/updater/client_updater.py` remains the single owner for feed
|
||||
validation, version comparison, download, install locking and rollback.
|
||||
GET reads a local snapshot; POST allowlists `check_only` and `update`.
|
||||
Opening the tab checks without installation or changing the automatic flag.
|
||||
The panel polls local state and replaces only its own markup, preserving form
|
||||
focus and edits elsewhere. Stage 1.0.40 supplies the extended socket contract.
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ APP_DIR = "/opt/iomatex-console"
|
|||
PUBLIC_DIR = os.path.join(APP_DIR, "public")
|
||||
PROVIDERS_DIR = os.path.join(APP_DIR, "providers.d")
|
||||
CONFIG_PATH = "/etc/iomatex/console.json"
|
||||
UI_VERSION = "V 3.1.28"
|
||||
UI_VERSION = "V 3.1.32"
|
||||
STORAGE_HEALTH_COMMAND = "/usr/local/sbin/iomatex-storage-health"
|
||||
ZONEINFO_ROOT = "/usr/share/zoneinfo"
|
||||
|
||||
|
|
@ -2977,6 +2977,27 @@ def get_itscreen_binary_candidates():
|
|||
return [path for path in candidates if os.path.exists(path)]
|
||||
|
||||
|
||||
def client_update_request(action=None):
|
||||
"""Console adapter only: the privileged updater owns feeds and installation."""
|
||||
if action not in (None, "check_only", "update"):
|
||||
raise ValueError("Invalid client update action")
|
||||
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as connection:
|
||||
connection.settimeout(3)
|
||||
connection.connect("/tmp/itsupdater")
|
||||
if action:
|
||||
connection.sendall((json.dumps({"action": action}) + "\n").encode())
|
||||
connection.sendall(b'{"action":"get","key":"snapshot"}\n')
|
||||
with connection.makefile("rb") as stream:
|
||||
for _ in range(32):
|
||||
line = stream.readline(65537)
|
||||
if not line or len(line) > 65536:
|
||||
break
|
||||
payload = json.loads(line)
|
||||
if "snapshot" in payload:
|
||||
return {"ok": True, **payload["snapshot"]}
|
||||
raise RuntimeError("Client updater is unavailable; update the It-Screen system stage")
|
||||
|
||||
|
||||
def get_itscreen_app_version():
|
||||
version_re = re.compile(r"\b(\d+\.\d+\.\d+(?:\.\d+)?)\b")
|
||||
for binary_path in get_itscreen_binary_candidates():
|
||||
|
|
@ -3729,6 +3750,12 @@ class Handler(BaseHTTPRequestHandler):
|
|||
except Exception as exc:
|
||||
self.send_json({"ok": False, "error": str(exc)}, code=500)
|
||||
return
|
||||
if parsed.path == "/api/itscreen/update":
|
||||
try:
|
||||
self.send_json(client_update_request())
|
||||
except Exception as exc:
|
||||
self.send_json({"ok": False, "error": str(exc)}, code=503)
|
||||
return
|
||||
if parsed.path == "/api/itscreen/status":
|
||||
try:
|
||||
self.send_json(build_itscreen_status_payload())
|
||||
|
|
@ -3827,6 +3854,16 @@ class Handler(BaseHTTPRequestHandler):
|
|||
return
|
||||
if not self.require_auth(parsed):
|
||||
return
|
||||
if parsed.path == "/api/itscreen/update":
|
||||
payload = self.read_json_body()
|
||||
if not isinstance(payload, dict) or payload.get("action") not in ("check_only", "update"):
|
||||
self.send_json({"ok": False, "error": "Invalid update action"}, code=400)
|
||||
return
|
||||
try:
|
||||
self.send_json(client_update_request(payload["action"]))
|
||||
except Exception as exc:
|
||||
self.send_json({"ok": False, "error": str(exc)}, code=503)
|
||||
return
|
||||
if parsed.path == "/api/onvif/probe":
|
||||
payload = self.read_json_body()
|
||||
if payload is None:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const vm = require('node:vm');
|
||||
const source = fs.readFileSync(__dirname + '/../frontend/console.js', 'utf8');
|
||||
const ctx = {state: {itscreen: {}}, t: s => s, esc: s => String(s).replaceAll('<', '<')};
|
||||
vm.createContext(ctx);
|
||||
vm.runInContext(source.slice(source.indexOf(' function clientVersion('), source.indexOf(' async function loadClientUpdate(')), ctx);
|
||||
for (const [phase, label] of [['ready', 'A new client version'], ['not_required', 'latest client version'], ['updating', 'Installing client'], ['error', 'Client update failed']]) {
|
||||
ctx.state.itscreen.update = {state_update: phase, installed_version: 5010055, ready_version: 5010056, error: phase === 'error' ? '<error>' : '', busy: phase === 'updating'};
|
||||
const html = ctx.renderClientUpdate();
|
||||
assert.ok(html.includes(label));
|
||||
assert.ok(html.includes('5.1.55'));
|
||||
assert.ok(html.includes('5.1.56'));
|
||||
assert.equal(html.includes(' disabled '), phase === 'updating');
|
||||
assert.ok(!html.includes('<error>'));
|
||||
}
|
||||
assert.ok(source.includes('panel.innerHTML = renderClientUpdate()'), 'Polling updates only the updater panel, preserving form edits');
|
||||
console.log('Client update versions, available/current/error/busy states and local panel rendering passed');
|
||||
|
|
@ -12,6 +12,18 @@
|
|||
],
|
||||
translations: {
|
||||
ru: {
|
||||
"Check and update client": "Проверить и обновить версию",
|
||||
"Installed client": "Установленная версия клиента",
|
||||
"Available client": "Доступная версия клиента",
|
||||
"Checking client version...": "Проверяем версию клиента…",
|
||||
"A new client version is available": "Доступна новая версия клиента",
|
||||
"The latest client version is installed": "Установлена актуальная версия клиента",
|
||||
"Downloading client update...": "Загрузка обновления клиента…",
|
||||
"Installing client update...": "Установка обновления клиента…",
|
||||
"Client updated": "Клиент обновлён",
|
||||
"Client update failed": "Не удалось обновить клиент",
|
||||
"Updates come from git.iomatex.com. The client restarts; registration and settings are preserved.": "Обновления загружаются с git.iomatex.com. Клиент перезапустится; регистрация и настройки сохранятся.",
|
||||
|
||||
"Input/output relationship": "Связь входов и реле",
|
||||
"Independent inputs and outputs": "Независимые входы и выходы",
|
||||
"Toggle with memory": "Переключение с фиксацией",
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
{ mode: "test_by", label: "test.it-screen.by", host: "rest.test.it-screen.by" },
|
||||
{ mode: "custom", label: "Custom", host: "" }
|
||||
];
|
||||
const UI_VERSION = "V 3.1.28";
|
||||
const UI_VERSION = "V 3.1.32";
|
||||
const ITSCREEN_LOG_INITIAL_LINES = 50;
|
||||
const ITSCREEN_LOG_BUFFER_LIMIT = 300;
|
||||
const ITSCREEN_LOG_BATCH_MS = 250;
|
||||
|
|
@ -167,6 +167,9 @@
|
|||
networkRequest: null,
|
||||
network: null,
|
||||
itscreen: {
|
||||
update: null,
|
||||
updateLoading: false,
|
||||
updateCheckedAt: 0,
|
||||
loading: false,
|
||||
busyAction: "",
|
||||
data: null,
|
||||
|
|
@ -3084,6 +3087,7 @@
|
|||
<button class="actionBtn secondary" type="button" ${canStopService ? "" : "disabled"} onclick="window.__itscreenServiceAction('stop')">${esc(busy === "service_stop" ? t("Stopping...") : t("Stop Service"))}</button>
|
||||
<button class="actionBtn secondary" type="button" ${busy ? "disabled" : ""} onclick="window.__itscreenRefresh()">${esc(state.itscreen.loading ? t("Refreshing...") : t("Refresh Status"))}</button>
|
||||
</div>
|
||||
<div id="itscreenClientUpdate">${renderClientUpdate()}</div>
|
||||
${serviceWarnings.length ? `<div class="list"><div class="listTitle">${esc(t("Warnings"))}</div><ul class="msgList">${serviceWarnings.map((x) => `<li>${esc(translateUiText(x))}</li>`).join("")}</ul></div>` : ""}
|
||||
${serviceErrors.length ? `<div class="list"><div class="listTitle">${esc(t("Errors"))}</div><ul class="msgList">${serviceErrors.map((x) => `<li>${esc(translateUiText(x))}</li>`).join("")}</ul></div>` : ""}
|
||||
${service && service.status === "not_installed" ? `<div class="formHint">${esc(t("It-screen service is not installed on this device."))}</div>` : ""}
|
||||
|
|
@ -5199,6 +5203,7 @@
|
|||
}
|
||||
|
||||
async function loadItscreenInitialData(options = {}) {
|
||||
if (state.activeTab === "tscreen") loadClientUpdate(Date.now() - state.itscreen.updateCheckedAt > 900000 ? "check_only" : null);
|
||||
const force = !!options.force;
|
||||
const maxAgeMs = Number.isFinite(options.maxAgeMs) ? options.maxAgeMs : 10000;
|
||||
if (!force && state.itscreen.request) return state.itscreen.request;
|
||||
|
|
@ -5832,6 +5837,58 @@
|
|||
state.itscreen.focused = !!focused;
|
||||
};
|
||||
|
||||
function clientVersion(code) {
|
||||
const n = Number(code);
|
||||
return n > 0 ? `${Math.floor(n / 1000000)}.${Math.floor(n / 10000) % 100}.${n % 10000}` : "—";
|
||||
}
|
||||
|
||||
function renderClientUpdate() {
|
||||
const u = state.itscreen.update || {};
|
||||
const phase = u.state_update || "init";
|
||||
const labels = {init: "Checking client version...", check: "Checking client version...",
|
||||
ready: "A new client version is available", not_required: "The latest client version is installed",
|
||||
downloading: "Downloading client update...", updating: "Installing client update...", not_permitted: "Automatic updates are disabled",
|
||||
updated: "Client updated", error: "Client update failed"};
|
||||
const busy = state.itscreen.updateLoading || u.busy;
|
||||
return `<div class="meta"><div class="key">${esc(t("Installed client"))}</div><div>${esc(clientVersion(u.installed_version))}</div>
|
||||
<div class="key">${esc(t("Available client"))}</div><div>${esc(clientVersion(u.ready_version))}</div></div>
|
||||
<div class="banner ${u.error ? "error" : phase === "ready" ? "warn" : ""}" role="status" aria-live="polite">${esc(t(labels[phase] || phase))}${phase === "downloading" ? ` ${Number(u.progress_download) || 0}%` : ""}${u.error ? `: ${esc(u.error)}` : ""}</div>
|
||||
<div class="actionColumn"><button class="actionBtn" type="button" ${busy || state.itscreen.busyAction ? "disabled" : ""} onclick="window.__clientUpdate()">${esc(t("Check and update client"))}</button></div>
|
||||
<div class="formHint">${esc(t("Updates come from git.iomatex.com. The client restarts; registration and settings are preserved."))}</div>`;
|
||||
}
|
||||
|
||||
async function loadClientUpdate(action = null) {
|
||||
if (state.itscreen.updateLoading) return;
|
||||
const generation = state.sessionGeneration;
|
||||
state.itscreen.updateLoading = true;
|
||||
if (action) renderClientUpdateStatus();
|
||||
try {
|
||||
const data = await fetchJson("/api/itscreen/update", action ? {
|
||||
method: "POST", headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({action})
|
||||
} : {cache: "no-store"});
|
||||
if (generation !== state.sessionGeneration) return;
|
||||
state.itscreen.update = data;
|
||||
if (action) state.itscreen.updateCheckedAt = Date.now();
|
||||
} catch (error) {
|
||||
if (generation !== state.sessionGeneration) return;
|
||||
state.itscreen.update = {state_update: "error", error: error.message};
|
||||
} finally {
|
||||
state.itscreen.updateLoading = false;
|
||||
if (generation === state.sessionGeneration) renderClientUpdateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
function renderClientUpdateStatus() {
|
||||
const panel = document.getElementById("itscreenClientUpdate");
|
||||
if (panel && state.activeTab === "tscreen") panel.innerHTML = renderClientUpdate();
|
||||
}
|
||||
|
||||
window.__clientUpdate = async function () {
|
||||
if (state.itscreen.updateLoading || state.itscreen.busyAction || (state.itscreen.update || {}).busy) return;
|
||||
await loadClientUpdate("update");
|
||||
};
|
||||
|
||||
window.__itscreenRefresh = async function () {
|
||||
state.itscreen.busyAction = "refresh";
|
||||
if (state.activeTab === "tscreen") renderActiveTab();
|
||||
|
|
@ -7040,5 +7097,8 @@
|
|||
if (state.activeTab === "tscreen") return;
|
||||
loadForActiveTab({ preserveEditing: true }).catch(() => {});
|
||||
}, 15000);
|
||||
setInterval(() => {
|
||||
if (state.auth.authenticated && state.activeTab === "tscreen") loadClientUpdate();
|
||||
}, 3000);
|
||||
setInterval(updateSessionMeter, 30000);
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
} catch (error) {}
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="/console.css?v=3.1.28&rev=edge-runtime-profile-1">
|
||||
<link rel="stylesheet" href="/console.css?v=3.1.32&rev=edge-runtime-profile-1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="shell">
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
</main>
|
||||
<div id="menuBackdrop" class="menuBackdrop" hidden></div>
|
||||
<div id="toastStack" class="toastStack" aria-live="polite" aria-atomic="true"></div>
|
||||
<script src="/console.i18n.js?v=3.1.28&rev=edge-runtime-profile-1"></script>
|
||||
<script src="/console.js?v=3.1.28&rev=edge-runtime-profile-1"></script>
|
||||
<script src="/console.i18n.js?v=3.1.32&rev=edge-runtime-profile-1"></script>
|
||||
<script src="/console.js?v=3.1.32&rev=edge-runtime-profile-1"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"version": "3.1.31"
|
||||
"version": "3.1.32"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue