Read the scripts dir live for the paste command, because choosing appdata moves it mid-wizard
This commit is contained in:
@@ -506,6 +506,27 @@ function vvDeferItem(btn, id, defer) {
|
||||
//
|
||||
// Only while it is still outstanding: once the mirror has joined, the partnership row in the
|
||||
// checklist above says so and a second copy of the panel is noise.
|
||||
// SCRIPTS_DIR is read live rather than baked into the page, because the wizard can MOVE it.
|
||||
//
|
||||
// Choosing appdata storage in step 1 triggers a migration, and step 2 renders in the same page
|
||||
// load — so anything PHP substituted at render time still names the pre-migration location. A
|
||||
// host that migrated was handed "bash /boot/config/plugins/varaverk/…" to paste, which does not
|
||||
// exist there. The command is the one thing on this panel that must be right: it is pasted into
|
||||
// a root terminal.
|
||||
//
|
||||
// api/setup.php?action=detect re-reads varaverk.cfg, so it reports wherever the install actually
|
||||
// ended up. Cached after the first call — the checklist re-renders on every action.
|
||||
let _vvScriptsDir = null;
|
||||
function vvScriptsDir() {
|
||||
if (_vvScriptsDir) return Promise.resolve(_vvScriptsDir);
|
||||
return fetch('/plugins/varaverk/api/setup.php?action=detect&_=' + Date.now())
|
||||
.then(r => r.json())
|
||||
.then(d => (_vvScriptsDir = (d && d.scripts_dir) || <?= json_encode(SCRIPTS_DIR) ?>))
|
||||
// Falling back to the render-time value is still better than no command at all; it is only
|
||||
// wrong in the case this function exists to handle, and the panel shows the path either way.
|
||||
.catch(() => (_vvScriptsDir = <?= json_encode(SCRIPTS_DIR) ?>));
|
||||
}
|
||||
|
||||
function vvRenderOnboardPanel(d) {
|
||||
const el = document.getElementById('vv-onboard-panel');
|
||||
if (!el) return;
|
||||
@@ -513,17 +534,18 @@ function vvRenderOnboardPanel(d) {
|
||||
const pt = (d.items || []).find(i => i.id === 'partnership');
|
||||
if (!partner || !pt || pt.ok) { el.innerHTML = ''; return; }
|
||||
|
||||
// Same derivation the Partnership tab uses: the command runs on THIS machine, so it must carry
|
||||
// this machine's SCRIPTS_DIR, and the terminal link must be this machine's web terminal.
|
||||
vvScriptsDir().then(dir => {
|
||||
el.innerHTML = '<hr class="vv-hr">'
|
||||
+ '<div class="vv-cl-title">Join the partnership</div>'
|
||||
+ vvRenderMirrorOnboard({
|
||||
ownerName: vvDetectedIdentity.primary,
|
||||
// This host's own web terminal — the command runs here, not on the owner.
|
||||
termBase: `https://${window.location.hostname}/webterminal/ttyd/`,
|
||||
termCmd: <?= json_encode('bash ' . SCRIPTS_DIR . '/Partnership/partnership_onboard.sh --phase1-only') ?>,
|
||||
termCmd: `bash ${dir}/Partnership/partnership_onboard.sh --phase1-only`,
|
||||
phase: vvDetectedIdentity.phase ?? 0,
|
||||
hasPartner: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Setup finishing used to change nothing on screen. The wizard simply stopped appearing on the
|
||||
|
||||
Reference in New Issue
Block a user