Skip to content

Commit aa009c6

Browse files
ADFA-5051: make the update source branch configurable (K2GO_DASH_BRANCH)
update-check and the REST rebuild now read the tracked branch from K2GO_DASH_BRANCH (default "main"), and the rebuild spawn is passed the same branch so both always agree on the source. Lets a test box point at a feature branch to exercise the live self-update before merging, without code changes; unset in production it tracks main exactly as before. Rides in the unreleased 1.2.0 (prod-safe, no version bump).
1 parent aa65610 commit aa009c6

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎static/dashboard/routes.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ apiRouter.post('/kiwix/delete', (req: Request, res: Response): void => {
241241
// restarting dash-node mid-run never kills it. Declared before the generic /:type/* routes.
242242
const REBUILD_SCRIPT = '/opt/iiab-android/tools/rebuild-dashboard.sh';
243243
const REBUILD_STATUS_FILE = '/var/run/dash-rebuild.status';
244+
// ADFA-5051: the remote branch that update-check compares against AND the rebuild pulls. Defaults to
245+
// mainline; set K2GO_DASH_BRANCH in the dash-node env to point a test box at a feature branch (e.g.
246+
// to exercise the live self-update before merging to main) without touching code. Keep it unset in
247+
// production so both always track main.
248+
const DASH_BRANCH = process.env.K2GO_DASH_BRANCH || 'main';
244249

245250
// Installed dash-node version (from package.json), so the module card can show it + compare.
246251
apiRouter.get('/system/version', (_req: Request, res: Response): void => {
@@ -268,7 +273,11 @@ apiRouter.post('/system/dashboard/rebuild', (_req: Request, res: Response): void
268273
if (!fs.existsSync(REBUILD_SCRIPT)) { res.status(500).json({ error: 'rebuild script not found' }); return; }
269274
try {
270275
// setsid => own session, so `pdsm restart dash-node` inside the script can't kill this run.
271-
const child = spawn('setsid', ['sh', REBUILD_SCRIPT], { detached: true, stdio: 'ignore' });
276+
// Pass the tracked branch so the REST rebuild and update-check always agree on the source.
277+
const child = spawn('setsid', ['sh', REBUILD_SCRIPT], {
278+
detached: true, stdio: 'ignore',
279+
env: { ...process.env, K2GO_BRANCH: DASH_BRANCH },
280+
});
272281
child.unref();
273282
res.status(202).json({ ok: true, state: 'running' });
274283
} catch (e: any) {
@@ -282,7 +291,7 @@ apiRouter.post('/system/dashboard/rebuild', (_req: Request, res: Response): void
282291
// clone and reuses its existing git auth (like the rebuild). Network-bound, so it runs with a timeout
283292
// and returns 503 (not 500) when the remote can't be reached, letting the app keep its last-known state.
284293
const UPDATE_CLONE_DIR = '/opt/iiab-android';
285-
const UPDATE_BRANCH = 'main';
294+
const UPDATE_BRANCH = DASH_BRANCH; // ADFA-5051: same branch the rebuild pulls (K2GO_DASH_BRANCH override)
286295
const UPDATE_PKG_IN_CLONE = 'static/dashboard/package.json';
287296

288297
/** Run git inside the on-device clone with a hard timeout; resolves stdout, rejects on non-zero/timeout. */

0 commit comments

Comments
 (0)