scheduler: add Array Starting / Array Stopping event triggers

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.
This commit is contained in:
Gmer4Lfe
2026-05-24 21:54:13 -04:00
parent 1540c62d3a
commit 655c520ae8
6 changed files with 126 additions and 24 deletions
@@ -0,0 +1,13 @@
#!/bin/bash
# Varaverk: run array_stopping.sh if enabled in the schedule (foreground — blocks until done).
php -r "
require_once '/usr/local/emhttp/plugins/varaverk/include/scheduler.php';
\$s = vv_schedule_load();
\$e = \$s['Orchestrators/array_stopping.sh'] ?? [];
if (empty(\$e['enabled'])) exit(0);
\$runner = '/usr/local/emhttp/plugins/varaverk/run_job.sh';
\$script = SCRIPTS_DIR . '/Orchestrators/array_stopping.sh';
if (!file_exists(\$script)) exit(0);
\$flags = !empty(\$e['log_enabled']) ? ' --log' : '';
passthru('bash ' . escapeshellarg(\$runner) . ' Orchestrators/array_stopping.sh ' . escapeshellarg(\$script) . \$flags);
" 2>/dev/null