[Plugin] CA User Scripts


Recommended Posts

This is fantastic... I was doing these via my own batch script. This is much easier! Thank you Squid!

 

A few thoughts/questions:

 

1) Can others share their scripts so we can incorporate into our system?

 

2) A little guidance for creating my own script... I have a script that executes a command inside one of my Dockers. The script goes something like:

 

docker exec -t -i 70201386b244 cp -R /config/folderA /app/sab/folderB/

The number above is the ID of the Docker I want to access. If I re-intsall the Docker, this number changes. Is there a way to switch out the docker ID with something that will survive a Docker re-install?

 

3) When doing something with Dynamix Schedules, am I correct to assume that it will run in the background?

 

Thanks,

 

H.

Link to comment

For my item 2) above, when I run the script, I get me message that says:

 

cannot enable tty mode on non tty input

 

My script is:

#!/bin/bash
echo "Updating Sickrage Edits"
echo "If failed, need to ensure ID of Docker is correct in the script."
docker exec -t -i 70201386b244 cp -R /config/sickrage-edits/gui/slick /app/sickrage/gui/

 

How can I fix this?

 

Thanks,

 

H.

Link to comment

For my item 2) above, when I run the script, I get me message that says:

 

cannot enable tty mode on non tty input

 

My script is:

#!/bin/bash
echo "Updating Sickrage Edits"
echo "If failed, need to ensure ID of Docker is correct in the script."
docker exec -t -i 70201386b244 cp -R /config/sickrage-edits/gui/slick /app/sickrage/gui/

 

How can I fix this?

 

Thanks,

 

H.

Not the expert on docker exec but I think it's because you're running it in interactive mode -i and it recognizes there is no console input. Try removing that switch

 

Sent from my LG-D852 using Tapatalk

 

 

Link to comment

 

 

This is fantastic... I was doing these via my own batch script. This is much easier! Thank you Squid!

 

A few thoughts/questions:

 

1) Can others share their scripts so we can incorporate into our system?

 

2) A little guidance for creating my own script... I have a script that executes a command inside one of my Dockers. The script goes something like:

 

docker exec -t -i 70201386b244 cp -R /config/folderA /app/sab/folderB/

The number above is the ID of the Docker I want to access. If I re-intsall the Docker, this number changes. Is there a way to switch out the docker ID with something that will survive a Docker re-install?

 

3) When doing something with Dynamix Schedules, am I correct to assume that it will run in the background?

 

Thanks,

 

H.

1 just post it.

2 yeah I guess in case of a install reinstall or an update through dockerMan the id can change.  I'll bang together a script you can call with the name and it will return the id

3 anything scheduled to run here uses dynamix schedules.  Scripts all run in the background and if there are multiple scheduled they will run concurrently

 

Sent from my LG-D852 using Tapatalk

 

 

Link to comment

 

 

This is fantastic... I was doing these via my own batch script. This is much easier! Thank you Squid!

 

A few thoughts/questions:

 

1) Can others share their scripts so we can incorporate into our system?

 

2) A little guidance for creating my own script... I have a script that executes a command inside one of my Dockers. The script goes something like:

 

docker exec -t -i 70201386b244 cp -R /config/folderA /app/sab/folderB/

The number above is the ID of the Docker I want to access. If I re-intsall the Docker, this number changes. Is there a way to switch out the docker ID with something that will survive a Docker re-install?

 

3) When doing something with Dynamix Schedules, am I correct to assume that it will run in the background?

 

Thanks,

 

H.

1 just post it.

2 yeah I guess in case of a install reinstall or an update through dockerMan the id can change.  I'll bang together a script you can call with the name and it will return the id

3 anything scheduled to run here uses dynamix schedules.  Scripts all run in the background and if there are multiple scheduled they will run concurrently

 

Sent from my LG-D852 using Tapatalk

Can't you just use the name of the container? That is what I do when I run a docker exec.

Link to comment

 

1 just post it.

2 yeah I guess in case of a install reinstall or an update through dockerMan the id can change.  I'll bang together a script you can call with the name and it will return the id

3 anything scheduled to run here uses dynamix schedules.  Scripts all run in the background and if there are multiple scheduled they will run concurrently

 

Sent from my LG-D852 using Tapatalk

 

Thank you Squid... The Docker ID is not needed per Saarg... Removing the -i fixed the problem as well in my script. Thank you very much!!

Link to comment
  • 4 weeks later...

Would it be possible to integrate this with Powerdown Package and specifically run scripts from shutdown / startup events. I'd like to run a script at startup instead of a cron schedule. So basically i need the script to be inside /boot/config/plugins/powerdown/rc.unRAID.d/

But if you already have the power down plugin, why is the script plugin involved?

Link to comment

Would it be possible to integrate this with Powerdown Package and specifically run scripts from shutdown / startup events. I'd like to run a script at startup instead of a cron schedule. So basically i need the script to be inside /boot/config/plugins/powerdown/rc.unRAID.d/

But if you already have the power down plugin, why is the script plugin involved?

Not that big a deal to handle (and then you basically will have a GUI to handle something you would normally have to do via the command line to do it with the powerdown functions)

 

Will add  in array start and array stop to the frequency options.  Should take about 10 minutes for me tonight....

Link to comment

Would it be possible to integrate this with Powerdown Package and specifically run scripts from shutdown / startup events. I'd like to run a script at startup instead of a cron schedule. So basically i need the script to be inside /boot/config/plugins/powerdown/rc.unRAID.d/

But if you already have the power down plugin, why is the script plugin involved?

Not that big a deal to handle (and then you basically will have a GUI to handle something you would normally have to do via the command line to do it with the powerdown functions)

 

Will add  in array start and array stop to the frequency options.  Should take about 10 minutes for me tonight....

 

Exactly. This script is about not having to touch the command line.

 

Sounds good, will try it out when it's updated :-)

Link to comment

Would it be possible to integrate this with Powerdown Package and specifically run scripts from shutdown / startup events. I'd like to run a script at startup instead of a cron schedule. So basically i need the script to be inside /boot/config/plugins/powerdown/rc.unRAID.d/

But if you already have the power down plugin, why is the script plugin involved?

Not that big a deal to handle (and then you basically will have a GUI to handle something you would normally have to do via the command line to do it with the powerdown functions)

 

Will add  in array start and array stop to the frequency options.  Should take about 10 minutes for me tonight....

 

Exactly. This script is about not having to touch the command line.

 

Sounds good, will try it out when it's updated :-)

Ahh... You're one of those guys ;)

Link to comment

Would it be possible to integrate this with Powerdown Package and specifically run scripts from shutdown / startup events. I'd like to run a script at startup instead of a cron schedule. So basically i need the script to be inside /boot/config/plugins/powerdown/rc.unRAID.d/

But if you already have the power down plugin, why is the script plugin involved?

Not that big a deal to handle (and then you basically will have a GUI to handle something you would normally have to do via the command line to do it with the powerdown functions)

 

Will add  in array start and array stop to the frequency options.  Should take about 10 minutes for me tonight....

 

Exactly. This script is about not having to touch the command line.

 

Sounds good, will try it out when it's updated :-)

Ahh... You're one of those guys ;)

So you must miss 6.0B6 with no dockerMan, and strictly docker run commands then
Link to comment

I'm trying to make a very basic script for one of my servers, and wonder if anyone can help as I'm clueless with them.

 

This is the scrip I need:

 

1-run mover

2-trim cache

3-check for array inactivity (monitor reads/writes?), if inactive for say 60 seconds go to 4

4-powerdown

 

1,2 and 4 are easy, any ideas how I can do 3?

Link to comment

I'm trying to make a very basic script for one of my servers, and wonder if anyone can help as I'm clueless with them.

 

This is the scrip I need:

 

1-run mover

2-trim cache

3-check for array inactivity (monitor reads/writes?), if inactive for say 60 seconds go to 4

4-powerdown

 

1,2 and 4 are easy, any ideas how I can do 3?

Easy way for 3 is to check if all the disks are spun down:  ie the "color" is green-blink for all the disks within /var/local/emhttp/disks.ini  More or less implies no activity.  (alternatively, use hdparm to check)

 

To do it the way that you want is to check each disks numReads and numWrites (once again within disks.ini), sleep for 60 seconds, and then check again.  If all the values are the same, then go to 4.

 

I can bang together a php script later if it'll help (with a return code you can check) -> hate doing stuff like this in bash.

 

Link to comment

Easy way for 3 is to check if all the disks are spun down:  ie the "color" is green-blink for all the disks within /var/local/emhttp/disks.ini  More or less implies no activity.  (alternatively, use hdparm to check)

 

Thanks, the easy way would work for me, but like I said I'm totally clueless with scripts, how do I add a line to check if they're all spun down?

 

This is my current script:

 

/usr/local/sbin/mover
/sbin/fstrim -v /mnt/cache
/usr/bin/sleep 180
/usr/local/sbin/powerdown

 

I'd like to replace the sleep line with the check for spun down disks.

Link to comment

lol  sure.. catch me as I'm doing the numReads / Writes version.  Gimme a couple min.  Assuming you want to exclude cache drive

 

If you're doing the other one I would still prefer it, avoids the server being on for an extra 15 minutes unnecessarily, the least you can set to spin down.

Link to comment

lol  sure right when I finish the easy version.  Gotta eat and spend time with the wife.  I'll get back to it in a bit

 

#!/usr/bin/php
<?PHP
function startsWith($haystack, $needle) {
  return $needle === "" || strripos($haystack, $needle, -strlen($haystack)) !== FALSE;
}
exec("/usr/local/sbin/mover");
exec("/sbin/fstrim -v /mnt/cache");

$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);

foreach ($disks as $disk) {
  if ( startsWith($disk['name'],"cache") ) { continue; }
  if ( $disk['name'] == "flash" ) { continue; }
  if ( (! strpos($disk['color'],"blink")) && (!strpos($disk['color'],"off")) ) {
    $flag = true;
  }
}
if ( ! $flag ) {
  exec("/usr/local/sbin/powerdown");
}

?>

Link to comment

Problem with the other method in quick testing is that tuneable (poll_attributes) has to be set to be less than whatever the sleep is for since disks.ini is only updated at that frequency.  I believe that spin downs take effect in disks.ini immediately.

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.