diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/event/disks_mounted/rebuild_cron b/Plugin/usr/local/emhttp/plugins/varaverk/event/disks_mounted/rebuild_cron index ed14857..216bf26 100755 --- a/Plugin/usr/local/emhttp/plugins/varaverk/event/disks_mounted/rebuild_cron +++ b/Plugin/usr/local/emhttp/plugins/varaverk/event/disks_mounted/rebuild_cron @@ -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(); diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/include/scheduler.php b/Plugin/usr/local/emhttp/plugins/varaverk/include/scheduler.php index a07951d..a400fbb 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/include/scheduler.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/include/scheduler.php @@ -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; }