Scheduler: extra args input on script rows
- Tools and Custom: args input always visible (translucent at rest, full on hover) - Orch children: args input hidden when orch is on, shown when orch is off (same toggle as the cron field — orch off = standalone mode) - vvRunJob/vvDryRun: pick up .vv-script-args value, POST as extra_args - run.php / dryrun.php: accept extra_args, validate against shell metacharacters, append to run_job.sh invocation (flows through SCRIPT_ARGS to the script) - CSS: .vv-script-args — 30% opacity at rest, 100% on hover/focus
This commit is contained in:
@@ -25,9 +25,28 @@ if ($location && (!str_starts_with($location, '/') || str_contains($location, '.
|
||||
exit;
|
||||
}
|
||||
|
||||
$runner = dirname(__DIR__) . '/run_job.sh';
|
||||
$flags = vv_job_flags($id);
|
||||
$locArg = $location ? ' ' . escapeshellarg('--location=' . $location) : '';
|
||||
exec('nohup bash ' . escapeshellarg($runner) . ' ' . escapeshellarg($id) . ' ' . escapeshellarg($script) . ($flags ? " $flags" : '') . ' --manual' . $locArg . ' >> ' . escapeshellarg($logFile) . ' 2>&1 </dev/null &');
|
||||
$extra_args = trim($_POST['extra_args'] ?? '');
|
||||
if ($extra_args && preg_match('/[;&|`$<>\\\\"\']/', $extra_args)) {
|
||||
echo json_encode(['ok' => false, 'error' => 'Invalid extra_args']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Refuse if already running — scripts will lock-exit anyway, but surface it clearly.
|
||||
$statFile = vv_job_stat_path($id);
|
||||
if (file_exists($statFile)) {
|
||||
$stat = json_decode(file_get_contents($statFile), true) ?: [];
|
||||
$pid = $stat['pid'] ?? null;
|
||||
$status = $stat['status'] ?? '';
|
||||
if ($status === 'running' && $pid && file_exists("/proc/{$pid}")) {
|
||||
echo json_encode(['ok' => false, 'already_running' => true, 'error' => 'Already running']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$runner = dirname(__DIR__) . '/run_job.sh';
|
||||
$flags = vv_job_flags($id);
|
||||
$locArg = $location ? ' ' . escapeshellarg('--location=' . $location) : '';
|
||||
$extraStr = $extra_args ? ' ' . $extra_args : '';
|
||||
exec('nohup bash ' . escapeshellarg($runner) . ' ' . escapeshellarg($id) . ' ' . escapeshellarg($script) . ($flags ? " $flags" : '') . ' --manual' . $locArg . $extraStr . ' >> ' . escapeshellarg($logFile) . ' 2>&1 </dev/null &');
|
||||
|
||||
echo json_encode(['ok' => true]);
|
||||
|
||||
Reference in New Issue
Block a user