Let the conf push seed a node that has no master.conf yet, which is the node it exists to seed

This commit is contained in:
Gmer4Lfe
2026-08-16 13:05:04 -04:00
parent 6d9c856514
commit 0fe3435033
2 changed files with 29 additions and 6 deletions
+17 -5
View File
@@ -296,9 +296,22 @@ function vv_push_master_conf(): array {
continue;
}
// Single SSH call: get remote SCRIPTS_DIR and verify plugin is installed,
// Configurations/ exists, and master.conf is already present.
// Any missing piece means the remote isn't ready — skip rather than push blind.
// Single SSH call: get remote SCRIPTS_DIR and verify the plugin is installed and
// Configurations/ exists. Any missing piece means the remote isn't ready — skip rather
// than push blind.
//
// It deliberately does NOT require master.conf to already be there. Requiring it meant
// this could only ever *update* a conf, never deliver one — and delivering is what Step 10
// of partnership_onboard.sh exists to do. Every conf is gitignored, so a freshly installed
// node has varaverk.cfg and Configurations/ (README.md is tracked, so the clone creates the
// dir) but no master.conf, and the push skipped exactly the node it was meant to seed.
//
// The two surviving checks still refuse a bare or half-installed host, so nothing is
// pushed into a directory that is not a Varaverk install.
//
// NOTE: this sends the owner's master.conf as-is, credentials included — TAILSCALE_API_KEY
// and WEBHOOK_SECRET among them. That is the accepted trade for one shared config across
// the mesh; a node you would not hand those to should not be a listed host.
// Remote command built as one PHP string and escapeshellarg()'d whole — shell_exec()
// adds its own `sh -c` layer locally, so a bare double-quoted string here would let
// the $(...)/${...} substitutions expand on HOST1 before ssh ever sees them, instead
@@ -308,13 +321,12 @@ function vv_push_master_conf(): array {
$remoteCmd = 'cfg=$(grep SCRIPTS_DIR /boot/config/plugins/varaverk/varaverk.cfg 2>/dev/null)'
. ' && sd=$(echo "$cfg" | grep -oP \'(?<=SCRIPTS_DIR=")[^"]+\')'
. ' && test -d "${sd}/Configurations"'
. ' && test -f "${sd}/Configurations/master.conf"'
. ' && echo "$sd"';
$probe = trim(shell_exec($sshBase . ' ' . escapeshellarg($remoteCmd)) ?: '');
if ($probe === '') {
$results[] = ['host' => $hostKey, 'ok' => false, 'ready' => false,
'error' => 'plugin not installed, dir missing, or master.conf absent — skipped'];
'error' => 'plugin not installed or Configurations/ missing — skipped'];
continue;
}