Files
dawnline/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/maint.uc
T
Aemeath 2f2aaf6c34
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
Dawnline 0.11.0
- Russian translation. The admin pages, the LuCI menu and the router's
  messages (errors, Health checks, update steps, the service log) come in
  Russian with the new luci-i18n-dawnline-ru package, released beside the
  app. LuCI shows it when its language is Russian, or "auto" with a Russian
  browser
- The translation installs with install.sh when LuCI is in Russian (or with
  --lang ru), follows every Dawnline update and rollback, and can be added
  or removed in Components → Dawnline → Translation
- The portal speaks the visitor's language: it opens in the system's
  language and switches between English and Russian in place, from the
  language pill beside its QR code. It carries its own translation and needs
  no package
- Set-up steps quote the apps' own menus word for word, in Russian too:
  AmneziaVPN is "+ → Insert → Continue" (it has no "Add server"), and the
  Mac and Windows menus of WireGuard and AmneziaWG have their real names
- Questions in the portal (Reconnect, Remove) read from the left edge and
  close with Cancel, without ×
- Numbers, sizes and dates follow the page's language. A server that can't
  start says why in one sentence; event details and service log lines read
  as whole sentences
- README in Russian (README_ru.md). rules/i18n.md: how strings are written
  and translated; CI checks the catalogs (npm run i18n:check)
2026-10-20 19:33:52 +03:00

91 lines
3.4 KiB
Ucode

// Dawnline rpcd methods: Diagnostics (Health, the service log), backups,
// export / import, and removing Dawnline.
import { _ } from 'dawnline.i18n';
import { slog_clear, admin_log } from 'dawnline.util';
import * as core from 'dawnline.core';
import * as apply from 'dawnline.apply';
import * as watchdog from 'dawnline.watchdog';
import * as upd from 'dawnline.updates';
import * as store from 'dawnline.store';
import * as health from 'dawnline.health';
import * as backup from 'dawnline.backup';
import { wrap } from 'dawnline.rpc.common';
function health_view(extra) {
return { ...(extra ?? {}), checks: health.health(), ...watchdog.view(core.load()) };
}
function service_log_clear(a) {
let removed = slog_clear(+a.older_days || 0);
if (removed)
admin_log('dawnline', 'cleared', null, 'the service log', `${removed} entr${removed == 1 ? 'y' : 'ies'}${+a.older_days ? ` older than ${a.older_days} days` : ''}`);
return { removed };
}
function backup_restore(a) {
let r = backup.backup_restore(a.name);
admin_log('dawnline', 'restored', 'backup', a.name);
return r;
}
function backup_upload(a) {
let r = backup.backup_upload(a.data);
admin_log('dawnline', 'restored', 'backup', 'from a file');
return r;
}
function export_all(a) {
let r = backup.export_json();
admin_log('dawnline', 'exported', null, 'all settings', 'the file holds private keys');
return r;
}
function import_all(a) {
let r = backup.import_json(a.data);
admin_log('dawnline', 'imported', null, 'settings from a file');
return r;
}
/** Remove Dawnline's state from the router (the package is removed by the UI afterwards). */
function uninstall(a) {
if (a.confirm != 'remove')
die(_('Type "remove" to confirm.'));
// Not in the middle of an update (opkg/apk may be installing Dawnline itself).
if (upd.busy())
die(_('An update is running: wait for it to finish, then remove Dawnline.'));
backup.backup_create('pre-remove');
// Stop first: the agent would put back what teardown removes, and could start an automatic update.
system('/etc/init.d/dawnline stop >/dev/null 2>&1; /etc/init.d/dawnline disable >/dev/null 2>&1');
apply.teardown();
store.transact((c, m) => {
let rm = [];
c.foreach(core.CONFIG, null, (s) => {
if (s['.type'] != 'settings')
push(rm, s['.name']);
});
for (let n in rm)
c.delete(core.CONFIG, n);
c.set(core.CONFIG, 'settings', 'settings');
c.set(core.CONFIG, 'settings', 'portal_enabled', '0');
});
return { ok: true };
}
export const methods = {
apply: { call: wrap((a) => apply.apply()) },
health: { call: wrap((a) => health_view()) },
health_fix: { args: { id: '' }, call: wrap((a) => health_view({ result: health.fix(a.id) })) },
service_log: { call: wrap((a) => watchdog.view(core.load())) },
service_log_clear: { args: { older_days: '' }, call: wrap(service_log_clear) },
backup_list: { call: wrap((a) => ({ backups: backup.backup_list() })) },
backup_create: { call: wrap((a) => ({ name: backup.backup_create(null) })) },
backup_restore: { args: { name: '' }, call: wrap(backup_restore) },
backup_delete: { args: { name: '' }, call: wrap((a) => ({ ok: backup.backup_delete(a.name) })) },
backup_read: { args: { name: '' }, call: wrap((a) => ({ data: backup.backup_read(a.name) })) },
backup_upload: { args: { data: '' }, call: wrap(backup_upload) },
'export': { call: wrap(export_all) },
'import': { args: { data: {} }, call: wrap(import_all) },
uninstall: { args: { confirm: '' }, call: wrap(uninstall) },
};