Squid Posted June 25, 2016 Share Posted June 25, 2016 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 it. (Or anything that I happen to run across here on the forum that will be of use to some people) Install it via Community Applications Only a couple included scripts: - Delete .DS_Store files from the array - Delete any dangling images from the docker.img file - Display the size of the docker container's log files (to see if a docker app is filling up the image file through excessive logging) Additional Scripts from myself (and hopefully other users) can be found here: To add your own scripts: Within the flash drive folder config/plugins/user.scripts/scripts create a new folder (each script is going to have its own folder) - The name doesn't matter but it can only contain the following characters: letters ([A-Za-z]), digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), periods ("."), and spaces (" ") Or, you can hit the button that says "Add Script", then give the script a name. Hovering over the script's name will then give you additional options. Including online editing... Create a file called description that contains the description of the script. Create a file called script this will be the actual script. Few notes: So as to make things easier for people: The script file can be created with any text editor you choose. DOS line endings will be automatically converted to Linux style endings prior to execution. #!bin/bash is automatically added to every script prior to execution to help out the noobies EDIT: This is only added if no interpreter is specified (ie: #!/bin/bash) If an interpreter is already specified (ie: #!/usr/bin/php), then line is not added Techie Notes: The scripts are actually copied and executed from /usr/local/emhttp/plugins/user.scripts/ /tmp/user.scripts/tmpScripts so if there are dependencies (other scripts, etc) stored in the same folder as the script file, you will need to specify the full path to them. Interactive (ie: answering yes/no to a question) scripts will not work. 6 2 3 Quote Link to comment
Squid Posted June 25, 2016 Author Share Posted June 25, 2016 (edited) The script file also supports some inline variables which will customize the GUI for the script in question description This is the description of the script - ie: what will show up on the UI for the plugin foregroundOnly Setting this to be true disallows background running (and scheduling) of the script backgroundOnly Setting this to be true disallows foreground running of the script arrayStarted Setting this to be true will only run the script (foreground or background or scheduled) if the array is up and running name this is the name of the script. Without this variable, the GUI will display the folder's name 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 clearLog Set to be true to have the log deleted prior to execution of the script (ie: logs are only for the last execution of the script) noParity Set to be try if the script is not allowed to run when a parity check / rebuild is in progress How to implement these variables: Immediately after the interpreter line (eg: immediately after the #!/bin/bash line), add these lines if you choose (you do not need to add all of them if you don't require them) #description=this is the description of the script #foregroundOnly=true #backgroundOnly=true #arrayStarted=true #name=blah blah blah #clearLog=true #argumentDescription=This is the description of the argument(s) #argumentDefault=defaultArg1 defaultArg2 etc #noParity=true After the first non comment line within any script, parsing for these variables stops. (IE: they have to be right at the top of the script file) Note that you do NOT have to have any or all of the lines contained within any particular script. (Also, if you do have the description file present, then its contents takes precedence over the description variable) *PHP scripters: You can also place these variable lines immediately after the <? or <?PHP line Edited March 31, 2018 by Squid add in clearLog variable 2 Quote Link to comment
CHBMB Posted June 26, 2016 Share Posted June 26, 2016 Nice.... I'll be using this one. Quote Link to comment
testdasi Posted June 26, 2016 Share Posted June 26, 2016 Very nice! I just added fstrim and mover scripts. Quote Link to comment
bonienl Posted June 26, 2016 Share Posted June 26, 2016 thanks squid, handy addition! Quote Link to comment
dlandon Posted June 26, 2016 Share Posted June 26, 2016 How about the option to run the script in the background so the webgui does not get tied up with the script. I just created a script to back up my VM and it takes a while. I'd like to be able to run the script and move on to other things while it runs. I will add a notification event to the script let me know it is done. Quote Link to comment
Squid Posted June 26, 2016 Author Share Posted June 26, 2016 How about the option to run the script in the background so the webgui does not get tied up with the script. I just created a script to back up my VM and it takes a while. I'd like to be able to run the script and move on to other things while it runs. I will add a notification event to the script let me know it is done. This should work as a script then: echo "Starting the real script" echo "/path/to/the/actual/script.sh" | at NOW -M > /dev/null 2>&1 Quote Link to comment
CHBMB Posted June 26, 2016 Share Posted June 26, 2016 How about the option to run the script in the background so the webgui does not get tied up with the script. I just created a script to back up my VM and it takes a while. I'd like to be able to run the script and move on to other things while it runs. I will add a notification event to the script let me know it is done. This should work as a script then: echo "Starting the real script" echo "/path/to/the/actual/script.sh" | at NOW -M > /dev/null 2>&1 I think this should be included in the plugin as a template. It's a good point and will definitely increase "usability" Quote Link to comment
dlandon Posted June 26, 2016 Share Posted June 26, 2016 Maybe add a second button to run the script in the background. That way the user could choose how to run the script without having to make script changes. Quote Link to comment
Squid Posted June 26, 2016 Author Share Posted June 26, 2016 Maybe add a second button to run the script in the background. That way the user could choose how to run the script without having to make script changes. let me finish my coffee, and then finish up a CA update so I can give CHBMB a good laugh EDIT: You guys are killing me... Anyone know what the odds are of a PID being reused after the script is completed? Quote Link to comment
dlandon Posted June 26, 2016 Share Posted June 26, 2016 echo "Starting the real script" echo "/path/to/the/actual/script.sh" | at NOW -M > /dev/null 2>&1 or echo "Starting the real script" at -f/path/to/the/actual/script.sh now 2>&1 /dev/null Quote Link to comment
Squid Posted June 26, 2016 Author Share Posted June 26, 2016 echo "Starting the real script" echo "/path/to/the/actual/script.sh" | at NOW -M > /dev/null 2>&1 or echo "Starting the real script" at -f/path/to/the/actual/script.sh now 2>&1 /dev/null Doesn't matter now. Adding a background button, along with status monitoring of background task, and an abort button Quote Link to comment
Squid Posted June 26, 2016 Author Share Posted June 26, 2016 Updated with ability to run the script as a background process, and monitoring of whether its running or not, along with the option to abort the script. BTW, if you want to format the output on any script, you would use standard HTML. Quote Link to comment
dlandon Posted June 26, 2016 Share Posted June 26, 2016 Updated with ability to run the script as a background process, and monitoring of whether its running or not, along with the option to abort the script. BTW, if you want to format the output on any script, you would use standard HTML. Very nice. Quote Link to comment
Squid Posted June 26, 2016 Author Share Posted June 26, 2016 Updated with ability to run the script as a background process, and monitoring of whether its running or not, along with the option to abort the script. BTW, if you want to format the output on any script, you would use standard HTML. Very nice. You want me to redirect the output of the script to a log file with the option to display it? Quote Link to comment
dlandon Posted June 26, 2016 Share Posted June 26, 2016 Updated with ability to run the script as a background process, and monitoring of whether its running or not, along with the option to abort the script. BTW, if you want to format the output on any script, you would use standard HTML. Very nice. You want me to redirect the output of the script to a log file with the option to display it? Hmm. Yes, I like that idea. Quote Link to comment
archedraft Posted June 26, 2016 Share Posted June 26, 2016 Updated with ability to run the script as a background process, and monitoring of whether its running or not, along with the option to abort the script. BTW, if you want to format the output on any script, you would use standard HTML. Very nice. You want me to redirect the output of the script to a log file with the option to display it? Lol, squid your so good at this point, you can anticipate user requests before they are even asked. Quote Link to comment
Squid Posted June 26, 2016 Author Share Posted June 26, 2016 Updated with ability to run the script as a background process, and monitoring of whether its running or not, along with the option to abort the script. BTW, if you want to format the output on any script, you would use standard HTML. Very nice. You want me to redirect the output of the script to a log file with the option to display it? Hmm. Yes, I like that idea. Couple of days... GoT night Sent from my LG-D852 using Tapatalk Quote Link to comment
CHBMB Posted June 27, 2016 Share Posted June 27, 2016 The more I've been thinking about this plugin the more I like it. Such a simple idea can't believe it hasn't been thought of before. Squid, what took you so long?! Quote Link to comment
Squid Posted June 27, 2016 Author Share Posted June 27, 2016 I saw a post the other day about unmenu and it popped back into my head about what it did (although iirc this is easier to add your own) Sent from my LG-D852 using Tapatalk Quote Link to comment
CHBMB Posted June 27, 2016 Share Posted June 27, 2016 I don't remember using it on unmemu, although I remember the button that was basically echo hello world I think. But I was new to Linux then..... Quote Link to comment
Squid Posted June 27, 2016 Author Share Posted June 27, 2016 I don't remember using it on unmemu, although I remember the button that was basically echo hello world I think. But I was new to Linux then..... As was I. Sent from my LG-D852 using Tapatalk Quote Link to comment
CHBMB Posted June 27, 2016 Share Posted June 27, 2016 Really?! Damn I got some catching up to do.... Quote Link to comment
BRiT Posted June 27, 2016 Share Posted June 27, 2016 i hope you enjoyed GoT. It's a great episode. If it were GRR Martin books it would span 3 books and take 16 years to release. Quote Link to comment
Squid Posted June 27, 2016 Author Share Posted June 27, 2016 Pretty much. Now I have no idea what to do on Sunday for the next 10 months Sent from my LG-D852 using Tapatalk Quote Link to comment
Recommended Posts
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.