[Plugin] CA User Scripts


1272 posts in this topic Last Reply

Recommended Posts

So should it look like this

 

#!/bin/bash
echo "Searching for (and deleting) .DS_Store Files"
echo "This may take a awhile"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \;

#!/bin/bash
echo "Searching for (and deleting) .AppleDB"
echo "This may take a awhile"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".AppleDB" -exec rm "{}" \;

 

Edited by squirrellydw
Link to post
  • Replies 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Just a simple little plugin to act as a front end for any little scripts that you may have that you may need to run every once in a while, and don't feel like dropping down to the command line to do i

I could make up something long, convoluted, and technical as a reason why it doesn't do that but it would all be bs.  The simple answer is that when I did this, I never thought of that, and why it sti

@Squid I tried many commands and by that I found out that pkill does not kill (all) child processes: root@Thoth:/tmp# pgrep -f isleep2m | xargs --no-run-if-empty ps fp PID TTY STAT T

Posted Images

On 3/5/2017 at 10:07 PM, tmchow said:

Having a weird issue using the "description" variable.

 

In the Clean Docker Logs script, I killed the description file and moved it to a variable with this as the first line of the script:
 


#description=Clean up docker log sizes on your system

However,  this doesn't work and the user scripts UI tells me no description is present

 

I removed one word at a time to see what was breaking it, and it wasn't until I removed the words "on your system" that it worked:


#description=Clean up docker log sizes

This isn't about line length since other scripts I'm using descriptions that are much longer, such as


#description=This script will display the size of your docker logs, so you can see if runaway logging is contributing to your docker.img file filling up

What am I missing?

Fixed

Link to post
5 hours ago, squirrellydw said:

So should it look like this

 

#!/bin/bash
echo "Searching for (and deleting) .DS_Store Files"
echo "This may take a awhile"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \;

#!/bin/bash
echo "Searching for (and deleting) .AppleDB"
echo "This may take a awhile"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".AppleDB" -exec rm "{}" \;

 

Yeah, that'll work.

 

Technically, you only require the first #!/bin/bash though....

Link to post
1 minute ago, Squid said:

Yeah, that'll work.

 

Technically, you only require the first #!/bin/bash though....

And just to nitpick, it should be "This may take a while". Not that it'll make any difference how the script runs.:D

Link to post

So this is what I have, do I need to change any of the other files?

#!/bin/bash
echo "Searching for (and deleting) .DS_Store Files"
echo "This may take a while"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \;
echo "Searching for (and deleting) ._.DS_Store Files"
echo "This may take a while"
find /mnt/user -maxdepth 9999 -noleaf -type f -name “._.DS_Store" -exec rm "{}" \;
echo "Searching for (and deleting) .AppleDB Files"
echo "This may take a while"
find /mnt/user -maxdepth 9999 -noleaf -type f -name “.AppleDB” -exec rm "{}" \;
echo "Searching for (and deleting) .AppleDesktop Files"
echo "This may take a while"
find /mnt/user -maxdepth 9999 -noleaf -type f -name “.AppleDesktop” -exec rm "{}" \;
echo "Searching for (and deleting) .AppleDouble Files"
echo "This may take a while"
find /mnt/user -maxdepth 9999 -noleaf -type f -name “.AppleDouble” -exec rm "{}" \;
echo "Searching for (and deleting) .TemporaryItems Files"
echo "This may take a while"
find /mnt/user -maxdepth 9999 -noleaf -type f -name “.TemporaryItems” -exec rm "{}" \;

Link to post

Better would be:

 

1 hour ago, squirrellydw said:

#!/bin/bash
echo "This may take a while"

 

echo "Searching for (and deleting) .DS_Store Files"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \;

 

echo "Searching for (and deleting) ._.DS_Store Files"
find /mnt/user -maxdepth 9999 -noleaf -type f -name "._.DS_Store" -exec rm "{}" \;

echo "Searching for (and deleting) .AppleDB Files"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".AppleDB" -exec rm "{}" \;

echo "Searching for (and deleting) .AppleDesktop Files"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".AppleDesktop" -exec rm "{}" \;

echo "Searching for (and deleting) .AppleDouble Files"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".AppleDouble" -exec rm "{}" \;

echo "Searching for (and deleting) .TemporaryItems Files"
find /mnt/user -maxdepth 9999 -noleaf -type f -name ".TemporaryItems" -exec rm "{}" \;
 

 

And I'm sure a bash scripter could shorten it with a loop, working on a list.

Edited by RobJ
improve wording
Link to post
9 hours ago, squirrellydw said:

I just ran this and I don't see the files but I still see some Folders with the same name, any idea how I can delete them?

 

For folders/directories, I believe you would use -type d instead of -type f.

Link to post
#!/bin/bash
echo "This may take a while"
 
echo "Searching for (and deleting) Apple Netatalk Files/Directories"
find /mnt/user -maxdepth 9999 -noleaf \( -type f \( -name ".DS_Store" -o -name "._.DS_Store" \) -o -type d \( -name ".AppleDB" -o -name ".AppleDesktop" -o -name ".AppleDouble" -o -name ".TemporaryItems" \) \) -exec rm -r "{}" \;

this should be much quicker. (only has to search one time through all directories.)

after deleting a directory, there can be an error message (because the find wants to search inside the directory but it doesn't exist anymore...

Edited by Benni-chan
Link to post

angif-boot-up-your-computer.gif

Added in support for a new schedule "At first array start" ->  Still executes at array start, but will only execute once (ie:  Will not execute again if you stop and restart the array).  Solves a problem for me where I kept on getting recursive symlinks getting created with every stop and start on one of my scripts

Edited by Squid
Link to post
41 minutes ago, Squid said:

Added in support for a new schedule "At bootup only" ->  Still executes at array start, but will only execute once (ie:  Will not execute again if you stop and restart the array).

 

It's a good option, but I think you will get complaints from some who actually want a true "At boot" option.  Might be better to call it something like "On first array start only".  Perhaps you can add a note that currently a true "at boot" option probably has to use the go file.

Link to post

Fixed wording.  Tell you what though...  I'll add in a true at boot this weekend...  It'll execute during plugin install.  Later than you can do things in the go file, but still before array start

 

Edited by Squid
Link to post

I suspect you are going to get some love for that!  But you'll have to tell them that since the array isn't running yet, there aren't many services running.  Other than the boot drive, there are no storage devices available.  And networking could be unreliable, as it gets reconfigured on array start.  I think I would want to add a note with it, that the feature is there but you aren't providing support for its use!

Link to post
Just now, RobJ said:

I suspect you are going to get some love for that!  But you'll have to tell them that since the array isn't running yet, there aren't many services running.  Other than the boot drive, there are no storage devices available.  And networking could be unreliable, as it gets reconfigured on array start.  I think I would want to add a note with it, that the feature is there but you aren't providing support for its use!

I don't support any script here lol....  I'll add appropriate warnings...

Link to post
On 3/15/2017 at 11:53 PM, RobJ said:

I suspect you are going to get some love for that!  But you'll have to tell them that since the array isn't running yet, there aren't many services running.  Other than the boot drive, there are no storage devices available.  And networking could be unreliable, as it gets reconfigured on array start.  I think I would want to add a note with it, that the feature is there but you aren't providing support for its use!

Thought about all of this, and I'm not going to do it.

 

Not because its hard (its not), but simply because if the script has errors, or goes haywire or something, diagnosis on startup issues would be a royal pain to diagnose.  

 

Any user who is capable enough to want to run a particular script at actual startup would also be capable enough to edit the go file themselves.

Link to post
  • 3 weeks later...

argumentDescription if present this will bring up a pop up asking the user for the argument list for the script.  Note that currently arguments do not accept spaces contained within one argument (ie: quoting and escaping spaces does NOT work)

argumentDefault this is the default arguments for the above

 

These options don't seem to be working after I upgraded to 6.3.3. Can anyone confirm or tell me if I did something wrong? Here's the start of my script:

#!/bin/bash
#description=description
#arrayStarted=true
#argumentDescription=Enter arguments
#argumentDefault=p1 p2
echo

Link to post

Hi @Squid I was wondering if in a future release of user scripts that you would consider making an edit script button to edit existing scripts. I find it a pain to have to open the flash then edit the script from there. Especially with my rare disease of "extremus-lazy-itus" :D

Link to post
On 4/3/2017 at 11:44 AM, rbronco21 said:

argumentDescription if present this will bring up a pop up asking the user for the argument list for the script.  Note that currently arguments do not accept spaces contained within one argument (ie: quoting and escaping spaces does NOT work)

argumentDefault this is the default arguments for the above

 

These options don't seem to be working after I upgraded to 6.3.3. Can anyone confirm or tell me if I did something wrong? Here's the start of my script:

#!/bin/bash
#description=description
#arrayStarted=true
#argumentDescription=Enter arguments
#argumentDefault=p1 p2
echo

You're doing it right.  You found a regression error of mine after the last update.  Fixed.

Link to post
On 4/4/2017 at 5:02 AM, gridrunner said:

Hi @Squid I was wondering if in a future release of user scripts that you would consider making an edit script button to edit existing scripts. I find it a pain to have to open the flash then edit the script from there. Especially with my rare disease of "extremus-lazy-itus" :D

On 7/6/2016 at 4:01 PM, Bjonness406 said:

Maybe a button to add new script aswell if you do this Squid  ;D

 

On 7/6/2016 at 2:02 PM, MyKroFt said:

Suggestion....

 

how about a button to edit via simple web text field the description/script after they have been added.

 

Just a simple form with 2 text boxes, one for the desc and one for the script?

 

Thanks

Myk

 

 

literature-jonah-bible-biblical-bible_st

 

 

OK....

 

If you're running unRaid 6.3.3+,

 

Hovering over a scripts name will bring up a couple of options:

 

Edit Name, Edit Description, Edit Script, and Delete Script

 

Edit name & description are both done in place, but Edit Script will open up a new spot at the bottom of the page where you can edit the script.

 

Additionally, a new button will also exist to Add a new script.

Link to post
12 hours ago, Squid said:

 

OK....

 

If you're running unRaid 6.3.3+,

 

Hovering over a scripts name will bring up a couple of options:

 

Edit Name, Edit Description, Edit Script, and Delete Script

 

Edit name & description are both done in place, but Edit Script will open up a new spot at the bottom of the page where you can edit the script.

 

Additionally, a new button will also exist to Add a new script.

 

 

Thanks, @Squid  I was was so excited I found I hit the donate button and just bought you a beer!! :D

Link to post
 
Thanks, [mention=10290]Squid[/mention]  I was was so excited I found I hit the donate button and just bought you a beer!! 

Thanks for that buddy... 6.3.3 is giving me new tools to make things easier on the ui

Sent from my LG-D852 using Tapatalk

Link to post

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.