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).
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
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'] ?? '';
|
||||
|
||||
// Must be an allowed file for this host
|
||||
$allowed = vv_get_conf_files();
|
||||
if (!$file || !in_array($file, $allowed)) {
|
||||
echo json_encode(['ok' => false, 'error' => 'File not permitted']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$ok = vv_write_conf_raw($file, $content);
|
||||
echo json_encode(['ok' => $ok, 'error' => $ok ? null : 'Failed to write file']);
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once dirname(__DIR__) . '/include/monitor.php';
|
||||
|
||||
echo json_encode([
|
||||
'fallback' => vv_fallback_state(),
|
||||
'resources' => vv_system_resources(),
|
||||
'gpu' => vv_gpu_stats(),
|
||||
'gpu_procs' => vv_gpu_processes(),
|
||||
'containers' => vv_docker_containers(),
|
||||
'stopped' => vv_docker_stopped(),
|
||||
'transcode' => vv_transcode_sessions(),
|
||||
'ts' => time(),
|
||||
]);
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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']);
|
||||
Reference in New Issue
Block a user