feat(varaverk): add local .plg registration; remove dev-mode cron fallback
Create varaverk.plg on flash (/boot/config/plugins/varaverk/varaverk.plg). On boot, rebuild_cron copies it to /var/log/plugins/ so update_cron natively picks up varaverk.cron and merges it into /etc/cron.d/root. With the .plg in place the dev-mode direct-inject fallback in vv_cron_rebuild() is no longer needed and has been removed.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Rebuild /etc/cron.d/varaverk from schedule.json after every boot.
|
||||
# /etc/cron.d/ is RAM-based and wiped on reboot; schedule.json persists on flash.
|
||||
# Register plugin with Unraid's cron system and rebuild cron entries after every boot.
|
||||
# /var/log/plugins/ and /etc/cron.d/ are RAM-based and wiped on reboot.
|
||||
cp /boot/config/plugins/varaverk/varaverk.plg /var/log/plugins/varaverk.plg 2>/dev/null
|
||||
php -r "
|
||||
require_once '/usr/local/emhttp/plugins/varaverk/include/scheduler.php';
|
||||
\$schedule = vv_schedule_load();
|
||||
|
||||
@@ -67,19 +67,6 @@ function vv_cron_rebuild(array $schedule): bool {
|
||||
// Write to the plugin cron file; update_cron merges all plugin *.cron files into /etc/cron.d/root.
|
||||
if (file_put_contents(CRON_FILE, implode("\n", $lines)) === false) return false;
|
||||
exec('/usr/local/sbin/update_cron');
|
||||
|
||||
// update_cron only picks up .plg-registered plugins. In dev (no varaverk.plg registered),
|
||||
// inject our entries directly into the live root crontab so they take effect immediately.
|
||||
if (!file_exists('/var/log/plugins/varaverk.plg')) {
|
||||
$current = shell_exec('crontab -c /etc/cron.d -l 2>/dev/null') ?: '';
|
||||
$filtered = preg_replace('/^[^\n]*run_job\.sh[^\n]*\n?/m', '', $current);
|
||||
$ours = file_get_contents(CRON_FILE);
|
||||
$combined = rtrim($filtered) . "\n\n" . $ours . "\n";
|
||||
$tmp = tempnam('/tmp', 'varaverk_cron_');
|
||||
file_put_contents($tmp, $combined);
|
||||
exec('crontab -c /etc/cron.d - < ' . escapeshellarg($tmp));
|
||||
unlink($tmp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user