diff --git a/CHANGELOG.md b/CHANGELOG.md index 4459b30..557bf31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,7 +90,8 @@ own. - **A page change that cannot reach PasarGuard or Rebecca changes nothing.** Regenerating the page (a rebrand, a design switch, an update) replaced `sub.html` before copying it into the panel; if that copy failed, `sub.html` - was left newer than the page the panel serves. It is now put back. + was left newer than the page the panel serves. It is now put back, and on a + first activation, where there was no `sub.html` before, none is left behind. - **A valid page is never refused under load.** The structural check before every install, update and design switch read the page through `head | grep -q`. On a busy server `grep -q` could stop reading before `head` @@ -125,6 +126,12 @@ own. minimum-supported and detected versions. - `row-template uninstall` returns each panel to the page it had before Row-Template, and leaves a page you chose afterwards alone. +- **A scripted fresh install on a server with more than one supported panel + needs `RT_PANEL`.** 1.2 installed for 3X-UI there because it was the only + panel it supported; 1.3.0 does not guess which panel you meant, and stops + with a message naming `RT_PANEL=3xui|pasarguard|rebecca`. An interactive + install asks instead. Re-running the installer on an existing install, and + `row-template update`, keep the install's own panel and are unaffected. - The `on_hold` state on PasarGuard and Rebecca is shown as active: with its "starts on first connection" duration on PasarGuard, and with an unknown expiry on Rebecca, which does not give the page that duration diff --git a/installer/lib/row-template.sh b/installer/lib/row-template.sh index dfed5a9..f8e2527 100644 --- a/installer/lib/row-template.sh +++ b/installer/lib/row-template.sh @@ -2201,8 +2201,9 @@ rt_activate() { # fails puts the previous sub.html back before returning: the contract above # holds for every panel, and a caller that reports "nothing was changed" is # telling the truth. - local staged dir panel prev="" rc=0 + local staged dir panel prev="" had_live=0 rc=0 dir="$(dirname "$RT_LIVE")" + [ -f "$RT_LIVE" ] && had_live=1 panel="$(rt_panel_current)" if [ "$panel" != "3xui" ]; then rt_installer_complete || { rt_err "the installer's panel components are missing; run 'row-template update'."; return 1; } @@ -2223,6 +2224,8 @@ rt_activate() { if [ -n "$prev" ]; then rt_atomic_install "$prev" "$RT_LIVE" 644 \ || rt_err "could not put the previous page back at $RT_LIVE." + elif [ "$had_live" -eq 0 ]; then + rm -f -- "$RT_LIVE" # there was none before: leave none behind fi rm -f "$prev" rt_err "could not update the page in $(rt_panel_label "$panel")'s template directory." diff --git a/tests/installer-panel-rebecca.test.mjs b/tests/installer-panel-rebecca.test.mjs index df32888..65deb52 100644 --- a/tests/installer-panel-rebecca.test.mjs +++ b/tests/installer-panel-rebecca.test.mjs @@ -407,6 +407,17 @@ test('a failed panel refresh leaves sub.html and the placed page exactly as they assert.match(r.out, /^0$/m, 'no temporary copy is left behind'); assert.ok(readFileSync(placed).equals(beforePlaced), 'the page Rebecca serves never changed'); }); + /* ...and when there was no sub.html before, none is left behind (raised in + the second review of PR #6). */ + withHost({}, ({ run }) => { + const r = run([SETUP, + 'rm -f "$RT_LIVE"', + 'rt_panel_refresh_page() { return 1; }', + 'rc=0; rt_activate 2>/dev/null || rc=$?; echo "rc=$rc"', + '[ -e "$RT_LIVE" ] && echo "live-left-behind" || echo "live-absent"']); + assert.match(r.out, /rc=1/); + assert.match(r.out, /live-absent/, 'a failed first activation leaves no sub.html'); + }); }); /* --- manual activation --------------------------------------------------------- */