[Plugin] CA User Scripts


Recommended Posts

So I have a simple script that runs a curl command within a docker container using docker exec command. However the output I get is just a download progress before finishing. It works just fine however I'd like the output to show me the returned json from the api call. Running the same command in a shell shows me the response. So I'm wondering how to have the userscript also return the response instead of just showing a download.

Link to comment
3 hours ago, Sarge888 said:

So I have a simple script that runs a curl command within a docker container using docker exec command. However the output I get is just a download progress before finishing. It works just fine however I'd like the output to show me the returned json from the api call. Running the same command in a shell shows me the response. So I'm wondering how to have the userscript also return the response instead of just showing a download.

docker exec <container> curl -s <url>

 

Link to comment
8 hours ago, Sarge888 said:

That gets rid of the progress bar but does not show me the result. I should be recieving a api json response. Is there anyway to see that response in the output window?

 

I just created a new script with:

#!/bin/bash

docker exec binhex-krusader curl -s https://jsonplaceholder.typicode.com/todos/1

And I get the output:

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}

 

Does that not work for you?

Link to comment
On 9/19/2023 at 7:18 AM, KnifeFed said:

 

I just created a new script with:

#!/bin/bash

docker exec binhex-krusader curl -s https://jsonplaceholder.typicode.com/todos/1

And I get the output:

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}

 

Does that not work for you?

Yes that does work for me. I guess it's the curl command I'm using. It uses both the -b and -c variables which I now understand is why it's downloading something. But why it doesn't tell me the response like it does wen I run the command in the shell is beyond me. I'd share the command but it relates to a tracker site and I'm not sure if that's allowed here.

Link to comment
  • 2 weeks later...

Hello,

 

First of all I love this plugin, thanks for all your hard work!

 

Second: I'm having a small problem: there is a script running, but I can't seem to abort it. I already tried to abort it, yet it's still running and the "abort" button is missing. How can I stop the script?

 

(When I click the log, I can see the script is still running, it's still uploading files to my remote)

Link to comment

I just started using a script with the cron schedule 0 2 * * * (every day at 2am). Looking at my Pushover logs it happened at 5am. My best guess is I recently moved from PST time to EST time and 2am PST would be 5am EST. Going to /Settings/DateTime on my Unraid dashboard does say I'm in Eastern Time, however. Is it possible the plugin is still stuck on the old timezone?

 

Thank you!

Link to comment
19 hours ago, Mave said:

Hello,

 

First of all I love this plugin, thanks for all your hard work!

 

Second: I'm having a small problem: there is a script running, but I can't seem to abort it. I already tried to abort it, yet it's still running and the "abort" button is missing. How can I stop the script?

 

(When I click the log, I can see the script is still running, it's still uploading files to my remote)

I ended up rebooting, but surely there must be a better solution?

Link to comment

At Startup of Array and At Fist Start of Array Only are not working for me on two machines with 6.12.4

 

If you use either - then trying to run a script in background it simply wont do anything.

 

For example try to do a simple

 

echo "hello world" 1> /var/log/hello.log

 

in a new script

 

and then a cat /var/log/hello.log in the terminal afterwards - either by trying to run in background, or via array start -> nothing produced. You have to actually run the user-script manually in foreground - otherwise it wont work.

 

I recon this has something to do with scheduling? Happens for me on two systems - both on 6.12.4 ...

 

one of that brand new, and with very little plugins at all beside user scripts. No clue maybe its just me or I'm missing something very basic but both dont seem to do anything at all ... even on freshly created scripts of any name.

 

I since then moved to add this to my /boot/config/go ... works just fine (albeit before the array starts)

 

# wait 30 seconds then enable the crond jobs ...
/bin/bash -c 'sleep 30; /usr/bin/resticprofile --log /var/log/resticprofile schedule --all' &

 

Edit forgot to mention:

 

If I run the same script for example with a custom scheduler every 5 minutes it works just fine.

Edited by jit-010101
Link to comment

Array start and first array start works perfectly for me.  This is something I would notice very quickly due to my workflow.  Array start on my end is simply 3 beeps so I know everything is good to go.

 

First array start sets up a symlink that I couldn't live without to do any dev work.  

Link to comment
10 hours ago, Squid said:

Array start and first array start works perfectly for me.  This is something I would notice very quickly due to my workflow.  Array start on my end is simply 3 beeps so I know everything is good to go.

 

First array start sets up a symlink that I couldn't live without to do any dev work.  

 

I guessed as much ... how do you spawn the shell and should it create a log-file (if not could you add that - same as for cronjobs)? I wonder what's preventing it from writing to log files and crontab ... seems almost like its a permission error or something

Edited by jit-010101
Link to comment

Hi,

   I have the latest version of the plugin 2023.09.30, I noticed my script stopped running on the 25th of September. I can run through the GUI just fine or through the shell.  I have tried setting the script to run daily or hourly, but it won't invoke it automatically.  Any ideas, I can try to get things running again?

 

-rw------- 1 root root 3012 Oct 12 11:24 script

 

bash /boot/config/plugins/user.scripts/scripts/gphoto-sync/script
Edited by Sanjiv Patel
Link to comment

Question - I have a script that monitors my CPU temp. I have a command built in to have it 'run' once a minute. The script runs just fine, my question is if I set it to run on Array Start, will it automatically be terminated when the array is stopped? If not, is there some command I can add to the script to check the status of the array and to kill the script if the array is stopped?

Link to comment
20 hours ago, Lonewolf147 said:

my question is if I set it to run on Array Start, will it automatically be terminated when the array is stopped?

depends if there is something in the script which relys on the array ... lets say you have a binary which you are executing which is on the array, so when the array is stopped it wont run any further as it fails ...

 

or, if the script is a "always runner" ... then it will stop once the array is stopped ... sample

image.thumb.png.21bd201974dec57f6d26f5116e86da2e.png

 

20 hours ago, Lonewolf147 said:

If not, is there some command I can add to the script to check the status of the array and to kill the script if the array is stopped?

there sure is ... depends now on the upper case ... simple a file exist on your array ...

 

simple if / else rule --- if yes do you job ... if no ... exit out ... idk your script now but you will figure it ;)

FILE=/mnt/cache/system/check_array_file
if [ -f "$FILE" ]; then
    echo "$FILE exists."
else 
    echo "$FILE does not exist."
fi

 

  • Thanks 1
Link to comment
On 10/9/2023 at 2:37 PM, jit-010101 said:

At Startup of Array and At Fist Start of Array Only are not working for me on two machines with 6.12.4

 

If you use either - then trying to run a script in background it simply wont do anything.

 

For example try to do a simple

 

echo "hello world" 1> /var/log/hello.log

 

in a new script

 

and then a cat /var/log/hello.log in the terminal afterwards - either by trying to run in background, or via array start -> nothing produced. You have to actually run the user-script manually in foreground - otherwise it wont work.

 

I recon this has something to do with scheduling? Happens for me on two systems - both on 6.12.4 ...

 

one of that brand new, and with very little plugins at all beside user scripts. No clue maybe its just me or I'm missing something very basic but both dont seem to do anything at all ... even on freshly created scripts of any name.

 

I since then moved to add this to my /boot/config/go ... works just fine (albeit before the array starts)

 

# wait 30 seconds then enable the crond jobs ...
/bin/bash -c 'sleep 30; /usr/bin/resticprofile --log /var/log/resticprofile schedule --all' &

 

Edit forgot to mention:

 

If I run the same script for example with a custom scheduler every 5 minutes it works just fine.

 

Did you ever find a fix for this? I'm finding today that "on array start" scripts aren't running for me either. I'm not sure when the issue started since I don't often reboot my server, but I'm also on 6.12.4.

Link to comment
4 hours ago, hasown said:

I'm not sure when the issue started since I don't often reboot my server, but I'm also on 6.12.4.

actually personally i cant confirm this, here i also user scripts on array start and they sure work

 

samples which i would directly be aware off if not ...

image.thumb.png.a98189351b38e2b6ad841b036d058229.png

 

image.thumb.png.1ff1490b44d2c0a0c6fca08bf15d1c0a.png

 

also on 6.12.4

image.thumb.png.0dee2ec24b77e837afaf49ce888bc0de.png

 

did you check your logs if there are any fails ?

Link to comment
On 10/2/2023 at 8:24 AM, unr41dus3r said:

Feature Request:

Show the Time and Date when a default time frame is chosen.

"Daily" Every Day @ 00:01

"Weekly" Every Sunday @ 00:00

and so on.

 

At the moment i dont know which time frame is set. Show the information where you would put the custom cron for example.

Putting in my vote for this request.  Do all daily/weekly/monthly scripts initiate at the same time? Id like to have a little bit more granularity here.  

Link to comment
11 minutes ago, robw83 said:

Putting in my vote for this request.  Do all daily/weekly/monthly scripts initiate at the same time? Id like to have a little bit more granularity here.  

As far as I know they do.

 

You can control the start times to be exactly when you want using the Custom option.

Link to comment
1 hour ago, Steviewunda said:

Where do I find "/tmp/user.scripts/tmpScripts/Backup" in order to view my rsync logs?

you should see your logs on the user scripts page

 

image.thumb.png.b9d3eeeca6301bb18ce2a1cd8cc30f9b.png

 

if you manually want to copy them over

 

they are located in Ram ...

image.thumb.png.8d79b2b94e34019e2700f828772f0993.png

 

so a cp ..../log.txt /mnt/user/whereever ... will copy them to a persistent storage.

  • Like 1
  • Thanks 1
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.