#!/bin/bash
# Varaverk: run array_started.sh if enabled in the schedule (background — non-blocking).
php -r "
require_once '/usr/local/emhttp/plugins/varaverk/include/scheduler.php';
\$s = vv_schedule_load();
\$e = \$s['Orchestrators/array_started.sh'] ?? [];
if (empty(\$e['enabled'])) exit(0);
\$runner = '/usr/local/emhttp/plugins/varaverk/run_job.sh';
\$script = SCRIPTS_DIR . '/Orchestrators/array_started.sh';
if (!file_exists(\$script)) exit(0);
\$flags = !empty(\$e['log_enabled']) ? ' --log' : '';
exec('nohup bash ' . escapeshellarg(\$runner) . ' Orchestrators/array_started.sh ' . escapeshellarg(\$script) . \$flags . ' > /dev/null 2>&1 &');
" 2>/dev/null
