Files
Varaverk/Plugin/usr/local/emhttp/plugins/varaverk/api/scheduler.php
T
Gmer4Lfe 4ab3ddbc47 Add Varaverk plugin scaffold (PHP, unRAID native)
Plugin lives in Plugin/ — invisible to User Script Plugin.
dev_install.sh symlinks into /usr/local/emhttp/plugins/varaverk/ for development.

Pages: Monitor (5s poll), Scheduler (orchs + Advanced children, toggle + cron),
Config (raw editor, host-aware file access), Docs (markdown + live $VAR substitution).

API endpoints: monitor.php (JSON), scheduler.php (writes schedule.json + cron.d),
config.php (writes conf files with host permission check).

Includes: config.php (parser, host detection, var map), scheduler.php (job tree,
cron.d rebuild), monitor.php (docker, GPU, resources, fallback, transcode),
docs.php (file tree, var substitution, Parsedown renderer).
2026-05-23 16:19:12 -04:00

23 lines
713 B
PHP

<?php
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'] ?? '');
if (!$id) {
echo json_encode(['ok' => false, 'error' => 'Missing id']);
exit;
}
// Basic cron validation — 5 fields or empty
if ($cron && !preg_match('/^(\S+\s+){4}\S+$/', $cron)) {
echo json_encode(['ok' => false, 'error' => 'Invalid cron expression']);
exit;
}
$ok = vv_schedule_update($id, $enabled, $cron);
echo json_encode(['ok' => $ok, 'error' => $ok ? null : 'Failed to write schedule']);