diff --git a/Plugin/unraid/include/config.php b/Plugin/unraid/include/config.php index 190a376..dbf1635 100644 --- a/Plugin/unraid/include/config.php +++ b/Plugin/unraid/include/config.php @@ -37,14 +37,26 @@ function vv_push_master_conf(): array { continue; } - // Query the remote's varaverk.cfg so we SCP to their actual SCRIPTS_DIR, - // not ours — they may use a different appdata path (e.g. /mnt/cache vs /mnt/user). - $sshBase = 'ssh -i ' . escapeshellarg($sshKey) - . ' -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"') ?: ''); - preg_match('/SCRIPTS_DIR\s*=\s*["\']?([^"\']+)["\']?/', $remoteCfg, $sm); - $remoteConf = rtrim($sm[1] ?? '/mnt/user/appdata/Varaverk', '/') . '/Configurations'; + // 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. + $sshBase = 'ssh -i ' . escapeshellarg($sshKey) + . ' -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@' . $ip; + $probe = trim(shell_exec( + $sshBase . ' "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\""' + ) ?: ''); + 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'); $cmd = 'scp -i ' . escapeshellarg($sshKey) . ' -o ConnectTimeout=10 -o StrictHostKeyChecking=no'