Dawnline 0.14.1

- The updater started without a command, with one it doesn't know, or
  with an install of nothing prints its usage and exits. It no longer
  counts that as a failed update: nothing goes into the service log,
  Activity or the update history, and Components shows no failed job.
  `updater --help` prints the same usage
This commit is contained in:
Aemeath committed 2026-10-22 00:20:51 +03:00
1 parent dc0f159447
commit 0e526cd3ec
6 files changed
+61 -6

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-dawnline PKG_NAME:=luci-app-dawnline
PKG_VERSION:=0.14.0 PKG_VERSION:=0.14.1
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=MIT PKG_LICENSE:=MIT
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released # po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
@@ -24,6 +24,25 @@ import * as pkgs from 'dawnline.upd_pkgs';
import * as i18n from 'dawnline.i18n'; import * as i18n from 'dawnline.i18n';
import { _, L_ } from 'dawnline.i18n'; import { _, L_ } from 'dawnline.i18n';
const USAGE = `Usage:
updater check [app|amneziawg|packages]
updater install app | app@<tag> | app:reinstall | app:rollback
updater install amneziawg[:auto|slava|grey[:ru]] | amneziawg:rollback
updater install pkgs:<name,…>
updater auto
`;
// No command, one it doesn't know, or an install of nothing: the usage and exit, before anything is read or
// written (no job for Components, no history, nothing in the service log). Asked for help: the same, on stdout.
if (index([ '-h', '--help', 'help' ], ARGV[0]) >= 0) {
print(USAGE);
exit(0);
}
if (index([ 'check', 'install', 'auto' ], ARGV[0]) < 0 || (ARGV[0] == 'install' && !length(ARGV[1] ?? ''))) {
warn(USAGE);
exit(2);
}
// The phases and errors of a job LuCI started are in the admin's language (rpc/updates.uc hands it over). // The phases and errors of a job LuCI started are in the admin's language (rpc/updates.uc hands it over).
i18n.use(getenv('DAWNLINE_LANG')); i18n.use(getenv('DAWNLINE_LANG'));
@@ -313,7 +332,7 @@ function main() {
else if (job.action == 'auto') else if (job.action == 'auto')
auto(); auto();
else else
die('Usage: updater check [app|amneziawg|packages] | install <what> | auto'); die(USAGE);
job.state = 'done'; job.state = 'done';
phase(_('Finished')); phase(_('Finished'));
} }
@@ -5,7 +5,7 @@
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
import { _ } from 'dawnline.i18n'; import { _ } from 'dawnline.i18n';
export const VERSION = '0.14.0'; export const VERSION = '0.14.1';
/** GitHub repository with Dawnline releases (updates and the installer). */ /** GitHub repository with Dawnline releases (updates and the installer). */
export const REPO = 'tickcount/luci-app-dawnline'; export const REPO = 'tickcount/luci-app-dawnline';
export const RUN_DIR = '/var/run/dawnline'; export const RUN_DIR = '/var/run/dawnline';
+36
View File
@@ -0,0 +1,36 @@
// usr/libexec/dawnline/updater: a call without a command it knows prints the usage and changes nothing (no job for
// Components, no history, no "update failed" in the service log).
import * as fs from 'fs';
const REPO = `${sourcepath(0, true)}/../..`;
const UPDATER = `${REPO}/package/luci-app-dawnline/root/usr/libexec/dawnline/updater`;
const MODULES = `${REPO}/package/luci-app-dawnline/root/usr/share/ucode/*.uc`;
const JOB = '/var/run/dawnline/update-job.json';
/** The updater run with `args`: { code, out } (stdout and stderr together). */
function updater(args) {
let p = fs.popen(`ucode -L '${MODULES}' '${UPDATER}' ${args} 2>&1; echo "exit=$?"`, 'r');
let out = p.read('all') ?? '';
p.close();
let m = match(out, /exit=([0-9]+)\s*$/);
return { code: m ? +m[1] : -1, out: replace(out, /exit=[0-9]+\s*$/, '') };
}
test('without a command it knows: the usage, nothing written', () => {
for (let args in [ '', 'frobnicate', 'install', "install ''" ]) {
fs.unlink(JOB);
let r = updater(args);
eq(r.code, 2, `exit code for "${args}"`);
ok(index(r.out, 'Usage:') == 0, `usage for "${args}"`);
ok(index(r.out, 'updater install app | app@<tag>') > 0, `the commands for "${args}"`);
ok(!fs.access(JOB), `no job for "${args}"`);
}
});
test('asked for help: the usage, exit 0', () => {
for (let args in [ '-h', '--help', 'help' ]) {
let r = updater(args);
eq(r.code, 0, `exit code for "${args}"`);
ok(index(r.out, 'Usage:') == 0, `usage for "${args}"`);
}
});
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "dawnline-web", "name": "dawnline-web",
"version": "0.14.0", "version": "0.14.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "dawnline-web", "name": "dawnline-web",
"version": "0.14.0", "version": "0.14.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"qrcode-generator": "1.4.4" "qrcode-generator": "1.4.4"
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "dawnline-web", "name": "dawnline-web",
"version": "0.14.0", "version": "0.14.1",
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",