[Plugin] CA User Scripts


Recommended Posts

I think the only thing I would ask for or suggest is a little popup or maybe something that can be explained when you click the help button that more or less says. "This is how you setup a basic custom Cron with maybe a few examples" I clicked on Custom and my Brain went into... Uh, How do I do this again. Lol

 

Yes I know Google is your friend, but just a minor suggestion and we all like being spoiled by you. ;)

I'm as guilty as a lot of other plugin guys here.  Functionality first.  Help files whenever we get around to it.    :D  (truth be told I never even thought about it)

 

After work it'll get done.

Link to comment

Quick question, I have a very simple script to display the cache scrub status so I don't need to keep refreshing it or go to the console:

 

while true; do
    sleep 20
    btrfs scrub status /mnt/cache
    echo
done

 

Any way to clear the log so that it only displays the last status, instead of one after other:

scrub status for b675e964-7944-4715-9bb9-0425685b4e13
scrub started at Sun Jan 15 14:48:31 2017, running for 00:20:11
total bytes scrubbed: 1.37TiB with 0 errors

scrub status for b675e964-7944-4715-9bb9-0425685b4e13
scrub started at Sun Jan 15 14:48:31 2017, running for 00:20:31
total bytes scrubbed: 1.39TiB with 0 errors

scrub status for b675e964-7944-4715-9bb9-0425685b4e13
...

Link to comment

Quick question, I have a very simple script to display the cache scrub status so I don't need to keep refreshing it or go to the console:

 

while true; do
    sleep 20
    btrfs scrub status /mnt/cache
    echo
done

 

Any way to clear the log so that it only displays the last status, instead of one after other:

scrub status for b675e964-7944-4715-9bb9-0425685b4e13
scrub started at Sun Jan 15 14:48:31 2017, running for 00:20:11
total bytes scrubbed: 1.37TiB with 0 errors

scrub status for b675e964-7944-4715-9bb9-0425685b4e13
scrub started at Sun Jan 15 14:48:31 2017, running for 00:20:31
total bytes scrubbed: 1.39TiB with 0 errors

scrub status for b675e964-7944-4715-9bb9-0425685b4e13
...

You can hit the garbage can on the UI.

 

Or for something more automated, within the script add

rm /tmp/user.scripts/tmpScripts/nameOfScriptFolderOnFlashDrive/log.txt

 

Link to comment

Or for something more automated, within the script add

rm /tmp/user.scripts/tmpScripts/nameOfScriptFolderOnFlashDrive/log.txt

 

This would do but I'm getting:

 

rm: cannot remove '/tmp/user.scripts/tmpScripts/scrub_status_disks/log.txt': No such file or directory

Not sure.  It worked for me.  But on a re-read of your post, its not going to do what you want anyways.  I think you want to keep the log window open and have it continually update those lines.

 

For that, you're going to have to make this html and php.  Let me get back to you on that one.  Good little experiment if nothing else....

Link to comment

Not sure.  It worked for me.  But on a re-read of your post, its not going to do what you want anyways.  I think you want to keep the log window open and have it continually update those lines.

 

Yes, I want to keep the log window open and clear the screen before it's updated, instead of showing one after the other, but if it's not an easy thing don't worry about it, it's not a big deal.

Link to comment

Not sure.  It worked for me.  But on a re-read of your post, its not going to do what you want anyways.  I think you want to keep the log window open and have it continually update those lines.

 

Yes, I want to keep the log window open and clear the screen before it's updated, instead of showing one after the other, but if it's not an easy thing don't worry about it, it's not a big deal.

Its either do that or clean the house... Decisions, decisions...
Link to comment

Not sure.  It worked for me.  But on a re-read of your post, its not going to do what you want anyways.  I think you want to keep the log window open and have it continually update those lines.

 

Yes, I want to keep the log window open and clear the screen before it's updated, instead of showing one after the other, but if it's not an easy thing don't worry about it, it's not a big deal.

Doable.  It'll take an update to user.scripts to handle it though.  (the way that the logs are displayed currently does not allow the javascript <script> tag to be present (which is going to be required).  I can switch things around however to allow that to happen...  Won't be today though.
Link to comment

Doable.  It'll take an update to user.scripts to handle it though.  (the way that the logs are displayed currently does not allow the javascript <script> tag to be present (which is going to be required).  I can switch things around however to allow that to happen...  Won't be today though.

 

There's no rush, thanks

Link to comment

I think the only thing I would ask for or suggest is a little popup or maybe something that can be explained when you click the help button that more or less says. "This is how you setup a basic custom Cron with maybe a few examples" I clicked on Custom and my Brain went into... Uh, How do I do this again. Lol

 

Yes I know Google is your friend, but just a minor suggestion and we all like being spoiled by you. ;)

I'm as guilty as a lot of other plugin guys here.  Functionality first.  Help files whenever we get around to it.    :D  (truth be told I never even thought about it)

 

After work it'll get done.

 

If you're thinking of putting in full help on how to build a crontab, there's TONS of 'generators' out there that you could just borrow a bit of design from instead.

http://corntab.com/  has a pretty functional way of doing it that has most of the flexibility and basics that cron can do.

Link to comment

I think the only thing I would ask for or suggest is a little popup or maybe something that can be explained when you click the help button that more or less says. "This is how you setup a basic custom Cron with maybe a few examples" I clicked on Custom and my Brain went into... Uh, How do I do this again. Lol

 

Yes I know Google is your friend, but just a minor suggestion and we all like being spoiled by you. ;)

I'm as guilty as a lot of other plugin guys here.  Functionality first.  Help files whenever we get around to it.    :D  (truth be told I never even thought about it)

 

After work it'll get done.

 

If you're thinking of putting in full help on how to build a crontab, there's TONS of 'generators' out there that you could just borrow a bit of design from instead.

http://corntab.com/  has a pretty functional way of doing it that has most of the flexibility and basics that cron can do.

Currently there's a link to wikipedia for cron when you hit help.  Next update I'll change the link to corntab
Link to comment

Anybody else having problems with the abort command not actually aborting some scripts?

 

If I have a custom script that runs rclone, for example, and I run it in the background and then click abort at a later time, the log appears to show that it is aborting but it doesn't, and the script continues to run and the log continues on as if nothing happened.

 

Any ideas?

Link to comment

Anybody else having problems with the abort command not actually aborting some scripts?

 

If I have a custom script that runs rclone, for example, and I run it in the background and then click abort at a later time, the log appears to show that it is aborting but it doesn't, and the script continues to run and the log continues on as if nothing happened.

 

Any ideas?

Background processes that may get spawned by the script or a command in the script do not get aborted

 

Sent from my LG-D852 using Tapatalk

 

 

Link to comment

Anybody else having problems with the abort command not actually aborting some scripts?

 

If I have a custom script that runs rclone, for example, and I run it in the background and then click abort at a later time, the log appears to show that it is aborting but it doesn't, and the script continues to run and the log continues on as if nothing happened.

 

Any ideas?

Background processes that may get spawned by the script or a command in the script do not get aborted

 

Sent from my LG-D852 using Tapatalk

 

Got it, thanks!

Link to comment

Did the changes for rc9 and it's working great, thanks again.

 

Anyway to run a script that asks for user input? Similar to using read on the console, I'd like for it to ask for a couple of variables that would then be used in the script.

 

If it's not possible or easy to do just let me know and I'll do it a different way.

 

Forget this, it would be much better to use the script to find the variables I want based on the folder names, I'll just need to google how to do that.

 

 

Link to comment

Did the changes for rc9 and it's working great, thanks again.

 

Anyway to run a script that asks for user input? Similar to using read on the console, I'd like for it to ask for a couple of variables that would then be used in the script.

 

If it's not possible or easy to do just let me know and I'll do it a different way.

 

Forget this, it would be much better to use the script to find the variables I want based on the folder names, I'll just need to google how to do that.

Even though you striked out the question, I still did think about it.  Interactive (script asks you something in the middle of it) is more or less not doable at all.

 

Non-interactive with questions at the beginning is doable.  Out of town for a couple of days next week, so I'll try and remember to get to it next weekend.

Link to comment

Did the changes for rc9 and it's working great, thanks again.

 

Anyway to run a script that asks for user input? Similar to using read on the console, I'd like for it to ask for a couple of variables that would then be used in the script.

 

If it's not possible or easy to do just let me know and I'll do it a different way.

 

Forget this, it would be much better to use the script to find the variables I want based on the folder names, I'll just need to google how to do that.

Since this is odds on about the btrfs script, just bear in mind that ultimately what's going on is that the script in question with my posted update frequency calls the script every second (as per the variable in the lead script)

 

The demo is great for things like status displays, but not for say running the preclear_disk script.  (Although it is doable for stuff like that, but would require a big overhaul on the javascript which I would leave to better people than myself)

Link to comment

Since this is odds on about the btrfs script, just bear in mind that ultimately what's going on is that the script in question with my posted update frequency calls the script every second (as per the variable in the lead script)

 

The demo is great for things like status displays, but not for say running the preclear_disk script.  (Although it is doable for stuff like that, but would require a big overhaul on the javascript which I would leave to better people than myself)

 

This was for another script, the one I use to make an offline snapshot of all my VMs, unlike the online snapshot script that runs daily and deletes snapshots older than 7 days the offline script doesn't run on a schedule because I have to shutdown all VMs first, I try to run it manually once a week or any time I need to shut them down for other reasons, like when there's an unRAID update, so I wanted an easy way to choose the previous offline snapshot as source for the incremental update and also delete the older one based on the date on the folder name, I know almost nothing about scripts but I'm good at googling, so I found a way of doing this automatically that although I bet it's not elegant or close to the best way, it suits my purpose.

 

 

 

 

Link to comment

Anyway to run a script that asks for user input? Similar to using read on the console, I'd like for it to ask for a couple of variables that would then be used in the script.

Just pumped out an update that will work for this.  Couple of new inline variables to support it.

 

Prior to executing a script in the foreground, a popup will appear prompting for the arguments to use in the script

 

Sample bash script

#description=This is a demonstration of argument passing
#argumentDescription=Enter in the arguments
#argumentDefault=argument1 argument2

echo "Argument1: $1"
echo "Argument2: $2"

 

Couple of caveats:

 

Because the arguments are passed from HTML to javascript to bash and then finally to the bash/php script, spaces and escaped characters really mess it all up.  After banging my head against the wall for a bit with the existing framework, just decided to make a note to not pass any paths that have spaces contained within them (or escaped characters).  At some point, I'll redo the entire execution framework from the ground up to process this properly if there is demand for it.

 

Arguments are currently not processed for running a script in the background or on a schedule.  If your script has the ability to run both foreground and background, it must adjust itself accordingly to not having passed arguments to it when in background.  EDIT: Any default arguments if specified are passed to the script.

 

At some point when I get bored, I'm going to have to create a new posting detailing all of the variables available now that they are growing in number....

 

Link to comment

Cool, I think this can be very useful for some scripts.

Yeah, me too why I did it.  Just a major PITA to try and get quoted paths containing spaces (like "/mnt/user/My Movies") or escaped spaces (/mnt/user/My\ Movies) to work without a big overhaul.  Someday....
Link to comment

Hi,

 

I'm facing a problem wih two of my Docker containers. Hopefully this plugin can help me out.

 

I have set up my array and all of my containers to autostart after powering on my server (it shuts down at night).

Unfortunately some services of my Emby and JDownloader2 containers are not working until I actually restart them one more time manually.

For example the Emby container is not able to search for application updates and the auto reconnect function of JDownloader isn't working aswell.

I have no idea why this happens.

 

So restarting the containers through the webUI is fixing my issues.

My idea with this plugin was it to either use a script that does the 'restarting' for me after each array start or that maybe replaces the unRAID autostart function for the two containers so that they start with a delay or something. Maybe this would solve my problem.

 

As I don't really know how to write such a script. I'd like to kindly ask some of the experts in here to give me a hint or something. Maybe there is also another solution for my problem?

 

Link to comment

Personally I would try CA docker autostart manager and delay the start of those apps to see what happens first.

 

But if that doesn't work I would try this as a script running at startup.

 

sleep 300
docker stop emby
sleep 60
docker start emby

 

Sent from my SM-T560NU using Tapatalk

 

 

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.