Two hardcoded event-triggered entries appear at the top of the scheduler (array_started.sh / array_stopping.sh). They show an ⚡ Array Start / ⚡ Array Stop badge instead of a cron field and are enabled/disabled via the normal toggle. Static event scripts fire them via Unraid's event system: - event/disks_mounted/array_start_jobs → runs in background (non-blocking) - event/disks_unmounting/array_stop_jobs → runs foreground (blocks until done) vv_cron_rebuild() skips @array_* entries so they never land in the cron file. Scripts executed on each event are managed in master.conf via ARRAY_START_SCRIPTS and ARRAY_STOP_SCRIPTS arrays.
24 lines
830 B
PHP
24 lines
830 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
require_once dirname(__DIR__) . '/include/scheduler.php';
|
|
|
|
$id = trim($_POST['id'] ?? '');
|
|
$enabled = (bool)($_POST['enabled'] ?? false);
|
|
$cron = trim($_POST['cron'] ?? '');
|
|
$log_enabled = ($_POST['log_enabled'] ?? '0') === '1';
|
|
|
|
if (!$id) {
|
|
echo json_encode(['ok' => false, 'error' => 'Missing id']);
|
|
exit;
|
|
}
|
|
|
|
// Basic cron validation — 5 fields, or known @event trigger, or empty
|
|
if ($cron && !in_array($cron, ['@array_start', '@array_stop'], true)
|
|
&& !preg_match('/^(\S+\s+){4}\S+$/', $cron)) {
|
|
echo json_encode(['ok' => false, 'error' => 'Invalid cron expression']);
|
|
exit;
|
|
}
|
|
|
|
$ok = vv_schedule_update($id, $enabled, $cron, $log_enabled);
|
|
echo json_encode(['ok' => $ok, 'error' => $ok ? null : 'Failed to write schedule']);
|