diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/api/config.php b/Plugin/usr/local/emhttp/plugins/varaverk/api/config.php index aca63b4..8bc8587 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/api/config.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/api/config.php @@ -2,9 +2,8 @@ header('Content-Type: application/json'); require_once dirname(__DIR__) . '/include/config.php'; -$body = json_decode(file_get_contents('php://input'), true); -$file = trim($body['file'] ?? ''); -$content = $body['content'] ?? ''; +$file = trim($_POST['file'] ?? ''); +$content = $_POST['content'] ?? ''; // Must be an allowed file for this host $allowed = vv_get_conf_files(); diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/api/dryrun.php b/Plugin/usr/local/emhttp/plugins/varaverk/api/dryrun.php new file mode 100644 index 0000000..5e3965d --- /dev/null +++ b/Plugin/usr/local/emhttp/plugins/varaverk/api/dryrun.php @@ -0,0 +1,26 @@ + false, 'error' => 'Invalid id']); + exit; +} + +$script = SCRIPTS_DIR . '/' . $id; +if (!file_exists($script)) { + echo json_encode(['ok' => false, 'error' => 'Script not found: ' . $id]); + exit; +} + +$logFile = vv_job_log_path($id); +$logDir = dirname($logFile); +if (!is_dir($logDir)) mkdir($logDir, 0755, true); + +file_put_contents($logFile, date('[Y-m-d H:i:s]') . " [DRY RUN] started\n", FILE_APPEND); + +exec('nohup env DRY_RUN=1 bash ' . escapeshellarg($script) . ' >> ' . escapeshellarg($logFile) . ' 2>&1 true]); diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/api/log.php b/Plugin/usr/local/emhttp/plugins/varaverk/api/log.php index a1a62c3..f5b0415 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/api/log.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/api/log.php @@ -2,7 +2,7 @@ header('Content-Type: application/json'); require_once dirname(__DIR__) . '/include/scheduler.php'; -$id = trim($_GET['id'] ?? ''); +$id = trim($_SERVER['REQUEST_METHOD'] === 'POST' ? ($_POST['id'] ?? '') : ($_GET['id'] ?? '')); if (!$id || !preg_match('/^[a-zA-Z0-9_.\/\-]+\.sh$/', $id) || str_contains($id, '..')) { echo json_encode(['ok' => false, 'error' => 'Invalid job id']); @@ -11,7 +11,7 @@ if (!$id || !preg_match('/^[a-zA-Z0-9_.\/\-]+\.sh$/', $id) || str_contains($id, $logFile = vv_job_log_path($id); -if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_GET['clear'])) { +if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['clear'])) { if (file_exists($logFile)) file_put_contents($logFile, ''); echo json_encode(['ok' => true]); exit; diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/api/run.php b/Plugin/usr/local/emhttp/plugins/varaverk/api/run.php index e438617..bcf237f 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/api/run.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/api/run.php @@ -2,8 +2,7 @@ header('Content-Type: application/json'); require_once dirname(__DIR__) . '/include/scheduler.php'; -$body = json_decode(file_get_contents('php://input'), true); -$id = trim($body['id'] ?? ''); +$id = trim($_POST['id'] ?? ''); if (!$id || !preg_match('/^[a-zA-Z0-9_.\/\-]+\.sh$/', $id) || str_contains($id, '..')) { echo json_encode(['ok' => false, 'error' => 'Invalid id']); @@ -23,6 +22,6 @@ if (!is_dir($logDir)) mkdir($logDir, 0755, true); // Stamp the log so the panel shows when the run started file_put_contents($logFile, date('[Y-m-d H:i:s]') . " Manual run started\n", FILE_APPEND); -exec('bash ' . escapeshellarg($script) . ' >> ' . escapeshellarg($logFile) . ' 2>&1 &'); +exec('nohup bash ' . escapeshellarg($script) . ' >> ' . escapeshellarg($logFile) . ' 2>&1 true]); diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/api/scheduler.php b/Plugin/usr/local/emhttp/plugins/varaverk/api/scheduler.php index 7d7f6e4..30c716e 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/api/scheduler.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/api/scheduler.php @@ -2,10 +2,9 @@ header('Content-Type: application/json'); require_once dirname(__DIR__) . '/include/scheduler.php'; -$body = json_decode(file_get_contents('php://input'), true); -$id = trim($body['id'] ?? ''); -$enabled = (bool)($body['enabled'] ?? false); -$cron = trim($body['cron'] ?? ''); +$id = trim($_POST['id'] ?? ''); +$enabled = (bool)($_POST['enabled'] ?? false); +$cron = trim($_POST['cron'] ?? ''); if (!$id) { echo json_encode(['ok' => false, 'error' => 'Missing id']); diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/api/settings.php b/Plugin/usr/local/emhttp/plugins/varaverk/api/settings.php index 36ba32d..fc5f6c6 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/api/settings.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/api/settings.php @@ -1,8 +1,7 @@ false, 'error' => 'scripts_dir is required']); diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/css/varaverk.css b/Plugin/usr/local/emhttp/plugins/varaverk/css/varaverk.css index 1f5ac25..6d46a29 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/css/varaverk.css +++ b/Plugin/usr/local/emhttp/plugins/varaverk/css/varaverk.css @@ -61,6 +61,9 @@ .vv-run-btn { border-color: #2196f3 !important; color: #2196f3 !important; } .vv-run-btn:hover { background: #0d47a1 !important; color: #fff !important; border-color: #2196f3 !important; } +.vv-dry-btn { border-color: #ff9800 !important; color: #ff9800 !important; } +.vv-dry-btn:hover { background: #e65100 !important; color: #fff !important; + border-color: #ff9800 !important; } /* Log panel */ .vv-log-panel { margin-top: 10px; border-top: 1px solid #333; padding-top: 8px; } diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/pages/config.php b/Plugin/usr/local/emhttp/plugins/varaverk/pages/config.php index 3eda69d..57a3e3a 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/pages/config.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/pages/config.php @@ -50,19 +50,23 @@ $currentScriptsDir = SCRIPTS_DIR; diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/pages/scheduler.php b/Plugin/usr/local/emhttp/plugins/varaverk/pages/scheduler.php index dc37cc8..68df535 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/pages/scheduler.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/pages/scheduler.php @@ -23,6 +23,7 @@ $tree = vv_job_tree(); + @@ -55,6 +56,7 @@ $tree = vv_job_tree(); + @@ -83,20 +85,24 @@ $tree = vv_job_tree();