Unraid Plugin Have PLG call update_cron in pre/post setup


Recommended Posts

I'm putting together a plugin for Unraid to monitor how much time my drives spend in standby. I've got the plugin working and my next steps is to polish it a bit, but I can't figure out how to make it install the cron entry during install.

 

You can find the repo and PLG here:  Github - DriveStandbyMonitor

 

I've tried to call it directly from a pre and post install section in the PLG, I've also tried a PHP variation I found in one of the other plugins, but no luck. Can anyone shine some light on this?

Edited by EldonMcGuinness
Link to comment
9 hours ago, EldonMcGuinness said:

I'm putting together a plugin for Unraid to monitor how much time my drives spend in standby. I've got the plugin working and my next steps is to polish it a bit, but I can't figure out how to make it install the cron entry during install.

 

You can find the repo and PLG here:  Github - DriveStandbyMonitor

 

I've tried to call it directly from a pre and post install section in the PLG, I've also tried a PHP variation I found in one of the other plugins, but no luck. Can anyone shine some light on this?

This is the process I use to create a cron entry in my plugins is below, which is included in the Wrappers.

 

Looking at your plg, I dont see a reason why it is not working. Here is an example of my plugins plg https://github.com/SimonFair/USB_Manager/blob/main/usb_manager.plg but I dont create cron in the plg. Does the file get created on the boot drive when you install?

 

function parse_cron_cfg($plugin, $job, $text = "") {
  $cron = "/boot/config/plugins/$plugin/$job.cron";
  if ($text) file_put_contents($cron, $text); else @unlink($cron);
  exec("/usr/local/sbin/update_cron");
}

 

 

Link to comment

Yes, the file is there after the install and to make things even weirder, I can open a terminal after the install, run update_cron, and it will install the cron just fine.

 

I'll give your snippet a try. I'm looking at your plug and I'm not seeing that snippet, do you not call it during the install? 

 

Basically what I'm trying to achieve is to have the cron job get installed during the install process.

Edited by EldonMcGuinness
Link to comment
9 minutes ago, EldonMcGuinness said:

Yes, the file is there after the install and to make things even weirder, I can open a terminal after the install, run update_cron, and it will install the cron just fine.

 

I'll give your snippet a try. I'm looking at your plug and I'm not seeing that snippet, do you not call it during the install? 

 

Basically what I'm trying to achieve is to have the cron job get installed during the install process.

That is only used to create the cron file from gui pages. You don't need for your plugin, it was an example.

 

update_cron should just work if the file exists in /boot/config/plugin/YourPluginName/name.cron.

 

do you see you entry in here: cat /etc/cron.d/root

Link to comment

Yup, I see the file and again I can just call update_cron after the install via the terminal, or reboot the server, and the cron gets installed as it should. It just seems like you can't call update_cron during pre-/post-install. I don't need to create a cron via the pages, at least not yet, just a single cron that should be setup when the plugin is installed. By the way, did not know one could use fontawesome tags for icons! Cheers for that, though I do wish they would update to say FA6!

Link to comment
17 minutes ago, EldonMcGuinness said:

Yup, I see the file and again I can just call update_cron after the install via the terminal, or reboot the server, and the cron gets installed as it should. It just seems like you can't call update_cron during pre-/post-install. I don't need to create a cron via the pages, at least not yet, just a single cron that should be setup when the plugin is installed. By the way, did not know one could use fontawesome tags for icons! Cheers for that, though I do wish they would update to say FA6!

Strange just installed an seems to be find and as you say doesnt update cron, but remove removes it. Will look to see if I can see an option to fix.

Link to comment
28 minutes ago, EldonMcGuinness said:

Yup, I see the file and again I can just call update_cron after the install via the terminal, or reboot the server, and the cron gets installed as it should. It just seems like you can't call update_cron during pre-/post-install. I don't need to create a cron via the pages, at least not yet, just a single cron that should be setup when the plugin is installed. By the way, did not know one could use fontawesome tags for icons! Cheers for that, though I do wish they would update to say FA6!

Maybe try

 

<!--
DSM background start script.
-->
<FILE Name="/tmp/start_DrvStdbyMon" Mode="0770">
<INLINE>
#!/bin/bash

update_cron

# Remove the background start script.
rm -f /tmp/start_DrvStdbyMon 2>/dev/null
</INLINE>
</FILE>


and add post script.

at -M -f /tmp/start_DrvStdbyMon now 2>/dev/null

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.