HarryMuscle Posted November 15, 2021 Share Posted November 15, 2021 Does anyone know the GitHub repo for this plugin? I'd like to look though the source code. Thanks, Harry Quote Link to comment
itimpi Posted November 15, 2021 Share Posted November 15, 2021 4 hours ago, HarryMuscle said: Does anyone know the GitHub repo for this plugin? I'd like to look though the source code. Thanks, Harry If you have the plugin installed then you can always look at the .txz file in the plugins folder on the flash drive without bothering to go to GitHub. Quote Link to comment
Squid Posted November 15, 2021 Author Share Posted November 15, 2021 On 11/4/2021 at 9:47 AM, niwmik said: 50 2 * * 4 [ $(date +%d) -le 07 ] You're going to want to add a cron job via crontab or by placing an application .cron file within /config/dynamix on the flash drive. User scripts will eventually disallow a cron entry like this (when I get to it) Quote Link to comment
azche24 Posted November 19, 2021 Share Posted November 19, 2021 I don't know if this belongs here: Had serious trouble with rsync commands running wild. Started something like "rsync -avh --delete \\A \\b - huge job, almost 10 TB. I canceled it via userscript-plugin but it did not work. In the end i had about 10 rsync scripts copying the same stuff over and over (because the first ones altered the date/time and the later scripts did not notice). Annoying... Is there a way to include this (i needed "killall rsync" to clean up this mess) or should i provide something with the script to avoid this behaviour. Quote Link to comment
vw-kombi Posted November 19, 2021 Share Posted November 19, 2021 I love this - I have so many scripts for automation of everything. I just added a new one to rsync the radarr and sonarr backups out of appdata to external backup disks. What would make this perfect is if I could move the scripts around ? Quote Link to comment
vw-kombi Posted November 27, 2021 Share Posted November 27, 2021 I just noticed my cron based scripts last ran on 19th Nov. The dropdown daily, weekly, hourly ones are running fine. I have some scripts for this however : */5 * * * * - very 5 minutes sync video camera data to hidden laptop 30 23 * * * - Backups every night at 23:30 Any idea where I can go to rectify this ? In there a cron process that has stopped or something ? Quote Link to comment
Noim Posted November 28, 2021 Share Posted November 28, 2021 On 10/27/2021 at 4:51 PM, Noim said: @Squid My issue still persists. Here is a test script: After aborting it, the script process is still running: What am I doing wrong?! This is how it gets spawned if I press background process: The process 10197 survives if I press abort. Plugin is up-to-date and running on unraid 6.9.2. Because nobody cared, and the dev doesn't even publish the plugin on GitHub, so I could make a pull request I investigated by myself. The abort how it is implemented is flawed. This is my fix. Not elegant, but it works better than the current version. Starting at line 115 in exec.php: case 'abortScript': $script = isset($_POST['name']) ? urldecode(($_POST['name'])) : ""; $pid = file_get_contents("/tmp/user.scripts/running/$script"); exec("pkill -TERM -P $pid"); exec("kill -9 $pid"); $processListOutput = null; exec("ps aux | grep -i '/tmp/user.scripts/tmpScripts/$script' | grep -v grep", $processListOutput); foreach ($processListOutput as $emergencyKill) { $emergencyKill = str_replace("root","",$emergencyKill); $emergencyKill = trim($emergencyKill); $rawKill = explode(" ",$emergencyKill); logger("Kill pid: ".$rawKill[0]); exec("kill -9 ".$rawKill[0]); } @unlink("/tmp/user.scripts/running/$script"); file_put_contents("/tmp/user.scripts/finished/$script","aborted"); file_put_contents("/tmp/user.scripts/tmpScripts/$script/log.txt","Execution was aborted by user\n\n",FILE_APPEND); break; The original version didn't kill all running script instances. And the grep command not even found the correct processes if I tried it manual. Quote Link to comment
Squid Posted November 28, 2021 Author Share Posted November 28, 2021 11 minutes ago, Noim said: dev doesn't even publish the plugin on GitHub, huh? https://github.com/Squidly271/user.scripts Quote Link to comment
Noim Posted November 28, 2021 Share Posted November 28, 2021 43 minutes ago, Squid said: huh? https://github.com/Squidly271/user.scripts Oh, I am sorry. There was no response to @HarryMuscle question and a quick google search wasn't helpful either. So, I just expected there is no repo. I will do a proper pull request. Quote Link to comment
seedless Posted December 21, 2021 Share Posted December 21, 2021 I created a script to run in the background, but today the log shows Full logs for this script are available at /tmp/user.scripts/tmpScripts/bypy_mmd/log.txt.Then the script failed to run after retrying several times automatically, and I had to restart the server to run normally.How to solve my trouble? Quote Link to comment
muddro Posted December 22, 2021 Share Posted December 22, 2021 Is there a possiblity of a GUI update to be able to organize the scripts within some type of folder structure to help keep them organized? Quote Link to comment
bobokun Posted January 3 Share Posted January 3 Is there a way to skip the Userscript from triggering if the previous run is still running? Currently it seems like the userscript will trigger a new run at the scheduled time even if the previous one is not complete. Quote Link to comment
primeval_god Posted January 3 Share Posted January 3 2 hours ago, bobokun said: Is there a way to skip the Userscript from triggering if the previous run is still running? Currently it seems like the userscript will trigger a new run at the scheduled time even if the previous one is not complete. I believe that the script itself would be responsible for ensuring that only a single instance can run at a time. Adding one of the solutions from this page https://unix.stackexchange.com/questions/48505/how-to-make-sure-only-one-instance-of-a-bash-script-runs would probably do the trick. Quote Link to comment
derpuma Posted January 8 Share Posted January 8 I have a problem with the plugin. I updated the user scripts plugin and afterwards it disappeared from my unraid menu and if I try to open it via the plugins > installed plugins tab and click on it, I get a black screen. Reinstall did not fix the problem. I am on Unraid Version: 6.10.0-rc1 Any ideas? Quote Link to comment
Sinister Posted January 14 Share Posted January 14 Hi i dont know the first thing about scripts but am able to follow instructions well. I am looking for a script that will start my pfsense VM when the array is brought up manually, i found something like "virsh start pfsense" which does not seem to work unless i run it manually after the array has started. can anyone assist me with this ? Quote Link to comment
alturismo Posted January 14 Share Posted January 14 1 hour ago, Sinister said: can anyone assist me with this ? may add a sleep in there as the array needs some time to startup (and the vm service too) the virsh start cmd is correct, here is my VM Cycle script which i made for me to switch VM's while running (Desktop VM with GPU passthrough), not your usecase now, but u see the sleep's i added between to make sure ... #!/bin/bash vm1="AlsLinux" vm2="AlsPC" ## vm_running="running" vm_down="shut off" vm1_state=$(virsh domstate "$vm1") vm2_state=$(virsh domstate "$vm2") echo "$vm1 is $vm1_state" echo "$vm2 is $vm2_state" if [ "$vm1_state" = "$vm_running" ] && [ "$vm2_state" = "$vm_down" ]; then echo "$vm1 is running shutting down" virsh shutdown "$vm1" vm1_new_state=$(virsh domstate "$vm1") until [ "$vm1_new_state" = "$vm_down" ]; do echo "$vm1 $vm1_new_state" vm1_new_state=$(virsh domstate "$vm1") sleep 2 done echo "$vm1 $vm1_new_state" sleep 2 virsh start "$vm2" sleep 1 vm2_new_state=$(virsh domstate "$vm2") echo "$vm2 $vm2_new_state" else if [ "$vm2_state" = "$vm_running" ] && [ "$vm1_state" = "$vm_down" ]; then echo "$vm2 is running shutting down" virsh shutdown "$vm2" vm2_new_state=$(virsh domstate "$vm2") until [ "$vm2_new_state" = "$vm_down" ]; do echo "$vm2 $vm2_new_state" vm2_new_state=$(virsh domstate "$vm2") sleep 2 done echo "$vm2 $vm2_new_state" sleep 2 virsh start "$vm1" sleep 1 vm1_new_state=$(virsh domstate "$vm1") echo "$vm1 $vm1_new_state" else echo "$vm1 $vm1_state and $vm2 $vm2_state doesnt match" fi fi so a simple vm start after array start (wait 15 seconds before vm start command) #!/bin/bash vm1="your_vm_name_here" sleep 15 virsh start "$vm1" and you set in CA scripts Quote Link to comment
Sinister Posted January 14 Share Posted January 14 (edited) 35 minutes ago, alturismo said: #!/bin/bash vm1="your_vm_name_here" sleep 15 virsh start "$vm1" So if i understand properly then my script would look like this: #!/bin/bash vm1="pfsense" sleep 15 virsh start "$vm1" where i could even move sleep to 30 ? Edited January 14 by Sinister Correcting script Quote Link to comment
Sinister Posted January 14 Share Posted January 14 47 minutes ago, alturismo said: may add a sleep in there as the array needs some time to startup (and the vm service too) the virsh start cmd is correct, here is my VM Cycle script which i made for me to switch VM's while running (Desktop VM with GPU passthrough), not your usecase now, but u see the sleep's i added between to make sure ... #!/bin/bash vm1="AlsLinux" vm2="AlsPC" ## vm_running="running" vm_down="shut off" vm1_state=$(virsh domstate "$vm1") vm2_state=$(virsh domstate "$vm2") echo "$vm1 is $vm1_state" echo "$vm2 is $vm2_state" if [ "$vm1_state" = "$vm_running" ] && [ "$vm2_state" = "$vm_down" ]; then echo "$vm1 is running shutting down" virsh shutdown "$vm1" vm1_new_state=$(virsh domstate "$vm1") until [ "$vm1_new_state" = "$vm_down" ]; do echo "$vm1 $vm1_new_state" vm1_new_state=$(virsh domstate "$vm1") sleep 2 done echo "$vm1 $vm1_new_state" sleep 2 virsh start "$vm2" sleep 1 vm2_new_state=$(virsh domstate "$vm2") echo "$vm2 $vm2_new_state" else if [ "$vm2_state" = "$vm_running" ] && [ "$vm1_state" = "$vm_down" ]; then echo "$vm2 is running shutting down" virsh shutdown "$vm2" vm2_new_state=$(virsh domstate "$vm2") until [ "$vm2_new_state" = "$vm_down" ]; do echo "$vm2 $vm2_new_state" vm2_new_state=$(virsh domstate "$vm2") sleep 2 done echo "$vm2 $vm2_new_state" sleep 2 virsh start "$vm1" sleep 1 vm1_new_state=$(virsh domstate "$vm1") echo "$vm1 $vm1_new_state" else echo "$vm1 $vm1_state and $vm2 $vm2_state doesnt match" fi fi so a simple vm start after array start (wait 15 seconds before vm start command) #!/bin/bash vm1="your_vm_name_here" sleep 15 virsh start "$vm1" and you set in CA scripts Thank you sir, worked like a charm 1 Quote Link to comment
Nuke Posted January 18 Share Posted January 18 (edited) i have a strange bug. i have test script, here it is: #!/bin/bash echo hello if i set cron to * * * * * then each minute all other scripts is force rebooting Is last versions is broken? Edited January 18 by Nuke Quote Link to comment
Squid Posted January 18 Author Share Posted January 18 8 hours ago, Nuke said: then each minute all other scripts is force rebooting What does that mean? Every other script runs every minute or the system is crashing? Quote Link to comment
bryce2113 Posted January 18 Share Posted January 18 On 11/27/2021 at 3:43 AM, vw-kombi said: I just noticed my cron based scripts last ran on 19th Nov. The dropdown daily, weekly, hourly ones are running fine. I have some scripts for this however : */5 * * * * - very 5 minutes sync video camera data to hidden laptop 30 23 * * * - Backups every night at 23:30 Any idea where I can go to rectify this ? In there a cron process that has stopped or something ? I'm having the same exact issue, but with a custom weekly schedule 06**0 -- weekly rsync to run every Sunday at 6AM. I've tested with some other custom date configurations and no luck. Quote Link to comment
sunbear Posted January 18 Share Posted January 18 Hi, I have an update request for the user scripts plugin I apologize if this is the wrong place for that. Is there anyway we could get a reorganization of the user scripts display? In my opinion, currently it feels very clunky and annoying to try to navigate and find my scripts. I currently have around 50 different scripts and am regularly adding more. The only way I've been able to manage them is to organize all my scripts into groups and the title the scripts with numbers according to those groups. I have to make sure I use the correct title when I add the script because it won't let me change the title again unless I delete and re-add it (I know I can edit the titles but that only changes what's displayed, the alphabetical position only ever uses the first title). And even with that, it's still takes me a good bit of scrolling back and forth to find my scripts. It feels like half of the page is basically not being used. You could reduce each script to use only one single line by moving the description to the right half of the page and reducing the button sizes if necessary. From a glance, it's kind of a pain to see which scripts are being used. Using some sort of colored icon scheme to visually show which scripts are scheduled, what type of schedule they are using, and perhaps any active scripts. And if I could have all my wishes, any easy way to shift different scripts around, organize them into folders that can be folded, and perhaps some kind of hover popups that show any descriptions with clickable links would be a godsend. This is just some basic functionality imagined by someone who has literally zero experience in GUI/web design. I'm sure someone with experience would be able to come up with something even better. I'm aware that this takes work and I would try to do it myself if I knew literally anything at all about web design, html, css, etc. So this is just my last resort. I apologize if others have made similar requests before. Thanks. Quote Link to comment
sunbear Posted January 18 Share Posted January 18 Just to reiterate my requests in a clearer format than a block of text, see my following list. Better utilization of full width of the page. Only one script (at least) per line. Foldable or popup script descriptions (w/ clickable url links?) Colored icon or other type of scheme for displaying script activity/status and schedule types at a glance. Script Organization: Ability to shift scripts around. Ability to group into folders. Minimize or hide unused scripts. Separate buttons for quickly renaming/editing description/editing the script each with a single click. Below are just some quick googled examples of things I had in mind. I'm only talking about the visual layout and organization functions of course. Even a slight resemblance to this would be much easier on my OCD brain. Thanks. Collapsible Sections: Activity/Status Icons & simple buttons for each function, some with dropdowns (e.g. for schedule type): Or another idea completely, have a permanently visible display of each script on the right, directly editable (Config File editor plugin is like this): Quote Link to comment
Ryonez Posted January 22 Share Posted January 22 (edited) I'm unable to fill a var via a command via scripts currently. Going back, I can see it stopped working correctly on the 14/12/21 (NZT). The command is this: #!/bin/bash -x DBLIST="$(docker exec -t alteria-postgres psql -U postgres -d postgres -q -t -A -c 'SELECT datname from pg_database')" echo "${DBLIST}" I'm at a loss atm, I can't think what would stop this, and the command can be run manually in the terminal, returning the list of databases correctly. The failure was very wonky as well. It saved all the databases fully, then I got zero bit files, then some had data but not all, then the script started running multiple times before outright just stopping. Overview of the base folder: Last Good Backup: When it started messing up Would anyone have any ideas what on earth happened and how to get this working? Edited January 22 by Ryonez More Info Quote Link to comment
CS01-HS Posted January 24 Share Posted January 24 I think there's a minor bug in the abort logic. With 2 scripts running in the background: myTest and myTestAlternate Aborting myTest aborts both (even though the display shows the latter as still running.) I figure the pattern-matching catches both. Not a big deal but FYI. I was trying to figure out why a script I wrote wasn't working, turns out it wasn't running because of the above. 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.