Add failsafes to vv_push_master_conf before SCPing
Single SSH probe per remote checks all three conditions in one call: - plugin cfg exists (varaverk.cfg present with SCRIPTS_DIR) - Configurations/ dir exists at that path - master.conf already present on remote Any failure skips that host entirely rather than pushing blind. Uses the discovered SCRIPTS_DIR as the SCP destination, not ours.
This commit is contained in:
@@ -37,14 +37,26 @@ function vv_push_master_conf(): array {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query the remote's varaverk.cfg so we SCP to their actual SCRIPTS_DIR,
|
// Single SSH call: get remote SCRIPTS_DIR and verify plugin is installed,
|
||||||
// not ours — they may use a different appdata path (e.g. /mnt/cache vs /mnt/user).
|
// Configurations/ exists, and master.conf is already present.
|
||||||
|
// Any missing piece means the remote isn't ready — skip rather than push blind.
|
||||||
$sshBase = 'ssh -i ' . escapeshellarg($sshKey)
|
$sshBase = 'ssh -i ' . escapeshellarg($sshKey)
|
||||||
. ' -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@' . $ip;
|
. ' -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@' . $ip;
|
||||||
$remoteCfg = trim(shell_exec($sshBase . ' "grep SCRIPTS_DIR /boot/config/plugins/varaverk/varaverk.cfg 2>/dev/null"') ?: '');
|
$probe = trim(shell_exec(
|
||||||
preg_match('/SCRIPTS_DIR\s*=\s*["\']?([^"\']+)["\']?/', $remoteCfg, $sm);
|
$sshBase . ' "cfg=$(grep SCRIPTS_DIR /boot/config/plugins/varaverk/varaverk.cfg 2>/dev/null)'
|
||||||
$remoteConf = rtrim($sm[1] ?? '/mnt/user/appdata/Varaverk', '/') . '/Configurations';
|
. ' && sd=$(echo \"$cfg\" | grep -oP \'(?<=SCRIPTS_DIR=\")[^\"]+\')'
|
||||||
|
. ' && test -d \"${sd}/Configurations\"'
|
||||||
|
. ' && test -f \"${sd}/Configurations/master.conf\"'
|
||||||
|
. ' && echo \"$sd\""'
|
||||||
|
) ?: '');
|
||||||
|
|
||||||
|
if ($probe === '') {
|
||||||
|
$results[] = ['host' => $hostKey, 'ok' => false,
|
||||||
|
'error' => 'plugin not installed, dir missing, or master.conf absent — skipped'];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$remoteConf = rtrim($probe, '/') . '/Configurations';
|
||||||
$dest = escapeshellarg('root@' . $ip . ':' . $remoteConf . '/master.conf');
|
$dest = escapeshellarg('root@' . $ip . ':' . $remoteConf . '/master.conf');
|
||||||
$cmd = 'scp -i ' . escapeshellarg($sshKey)
|
$cmd = 'scp -i ' . escapeshellarg($sshKey)
|
||||||
. ' -o ConnectTimeout=10 -o StrictHostKeyChecking=no'
|
. ' -o ConnectTimeout=10 -o StrictHostKeyChecking=no'
|
||||||
|
|||||||
Reference in New Issue
Block a user