Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1915f070b |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-dawnline
|
||||
PKG_VERSION:=0.14.0
|
||||
PKG_VERSION:=0.14.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_LICENSE:=MIT
|
||||
# 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 { _, 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).
|
||||
i18n.use(getenv('DAWNLINE_LANG'));
|
||||
|
||||
@@ -313,7 +332,7 @@ function main() {
|
||||
else if (job.action == 'auto')
|
||||
auto();
|
||||
else
|
||||
die('Usage: updater check [app|amneziawg|packages] | install <what> | auto');
|
||||
die(USAGE);
|
||||
job.state = 'done';
|
||||
phase(_('Finished'));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
||||
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). */
|
||||
export const REPO = 'tickcount/luci-app-dawnline';
|
||||
export const RUN_DIR = '/var/run/dawnline';
|
||||
|
||||
@@ -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}"`);
|
||||
}
|
||||
});
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "dawnline-web",
|
||||
"version": "0.14.0",
|
||||
"version": "0.14.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dawnline-web",
|
||||
"version": "0.14.0",
|
||||
"version": "0.14.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"qrcode-generator": "1.4.4"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dawnline-web",
|
||||
"version": "0.14.0",
|
||||
"version": "0.14.1",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
|
||||
Reference in new issue
Block a user