Sakashi Posted March 27 Share Posted March 27 (edited) Can you add theme Support for the PopUp window, when i click "run script" ? i have a issue for me: startScript.sh Quote #!/bin/bash echo "Script location: <b>$1</b>" echo "<style> body {background-color: #000000} </style>" echo "<body>" export HOME=$(grep $(whoami) /etc/passwd | cut -d: -f 6) source ${HOME}/.bashrc echo "<font color='red'>Note that closing this window will abort the execution of this script</font>" "$1" "$2" 2>&1 echo "</body>" I use unraid 6.12-rc2. I added "style" and "body" in this script and i can theme now. Maybe you can add theme support for the future versions. I added a picture for impressions. Picture: Spoiler regards Sakashi Edited March 27 by Sakashi Quote Link to comment
1971camaroguy Posted March 29 Share Posted March 29 I have a question, I am not 100% familiar with scripting so someone on another group helped me out with this. It's supposed to look at the trailers folder and compare it to my movies folder for a movie match and if a trailer isn't in that movies folder, and there is a match in the Trailers folder, it will copy it over, otherwise ignore the movie folder and move on. He wrote it assuming the script would be sitting in the same share (Storage-1) as the trailer and movie folder sits in. But I think with this pugin the script is in it's own folder in /boot/config/plugins/user.scripts/scripts I was wondering if someone could help me put the direct paths in this script so I can get it working? Right now the paths of my share and the two folders are structured like this, with Storage-1 being the main share folder. Storage-1 / Trailers Storage-1 / Movies Thanks for the help! Much appriciated #!/usr/bin/bash for trailer in Trailers/*; do echo "Searching for movie for Trailer - '$trailer'" basename=$(basename "$trailer" .mkv) basename=${basename%-trailer} basename=${basename/%.[[:digit:]][[:digit:]][[:digit:]][[:digit:]]/} basename=${basename/% ([[:digit:]][[:digit:]][[:digit:]][[:digit:]])/} basename=${basename/[/\\[} basename=${basename/]/\\]} matches=`find Movies -iname "$basename"\*` if [[ -n "${matches}" ]]; then num=$(echo -n "${matches}" | grep -c '^') if [[ "$num" == "1" ]]; then echo "--> Found match for trailer ${matches}" echo mv "$trailer" "${matches}" else echo "Multiple matches for trailer: ${trailer}" echo "${matches}" fi #else # echo "--> No match found for trailer ${matches}" fi done Quote Link to comment
Squid Posted March 29 Author Share Posted March 29 On 3/27/2023 at 3:04 PM, Sakashi said: Maybe you can add theme support for the future versions. Done. The popup window already follows the theme set by the webGUI. IE: it doesn't make any changes to the popup Quote Link to comment
1971camaroguy Posted March 29 Share Posted March 29 18 hours ago, 1971camaroguy said: I have a question, I am not 100% familiar with scripting so someone on another group helped me out with this. It's supposed to look at the trailers folder and compare it to my movies folder for a movie match and if a trailer isn't in that movies folder, and there is a match in the Trailers folder, it will copy it over, otherwise ignore the movie folder and move on. He wrote it assuming the script would be sitting in the same share (Storage-1) as the trailer and movie folder sits in. But I think with this pugin the script is in it's own folder in /boot/config/plugins/user.scripts/scripts I was wondering if someone could help me put the direct paths in this script so I can get it working? Right now the paths of my share and the two folders are structured like this, with Storage-1 being the main share folder. Storage-1 / Trailers Storage-1 / Movies Thanks for the help! Much appriciated #!/usr/bin/bash for trailer in Trailers/*; do echo "Searching for movie for Trailer - '$trailer'" basename=$(basename "$trailer" .mkv) basename=${basename%-trailer} basename=${basename/%.[[:digit:]][[:digit:]][[:digit:]][[:digit:]]/} basename=${basename/% ([[:digit:]][[:digit:]][[:digit:]][[:digit:]])/} basename=${basename/[/\\[} basename=${basename/]/\\]} matches=`find Movies -iname "$basename"\*` if [[ -n "${matches}" ]]; then num=$(echo -n "${matches}" | grep -c '^') if [[ "$num" == "1" ]]; then echo "--> Found match for trailer ${matches}" echo mv "$trailer" "${matches}" else echo "Multiple matches for trailer: ${trailer}" echo "${matches}" fi #else # echo "--> No match found for trailer ${matches}" fi done I got my issue sorted out, moving and matching trailers as expected now Quote Link to comment
codefaux Posted March 29 Share Posted March 29 (edited) Could you be convinced to add a variable to pipe stdout to a specific path? My target: prometheus_node_exporter contains a textfile collector. There are a handful of community scripts designed to - be run from cron (ie your plugin on a custom schedule) - collect useful (I'd argue critical) system metrics (ie smartmon stats like temps and failure indicators) for prometheus-node-exporter - output data to stdout, to be piped to a file The inconvenience is, to use these is not straightforward. They would require extensive modification most users can't grok. Thanks to your plugin, an alternative is to manually save them to disk someplace, then use your plugin to write a script which runs them with stdout piped to a file, scheduled cron-alike. EDIT: These are the same script, ignore the name difference I used an old screenshot for the one by mistake This is workable but some users may still find this unapproachable. If the user could paste the entire script (in my case, /boot/config/scripts/smartmon.sh aka smartmon.sh [raw] among others) into a User Script, schedule them as cron-alikes, and mark their output to be sent to a specific path, it would make these more approachable. It could be implemented similar to the variables you've recently added; an STDOUT variable could be changed to request redirection. Regardless of your decision, keep up the great work. The plugin has been quite valuable for many of us! Edited March 29 by codefaux derp old screenshot Quote Link to comment
Presjar Posted April 4 Share Posted April 4 On 3/9/2023 at 1:48 PM, Presjar said: Is it a problem if a CA script I have set to run on start of the array never completes when I test with "RUN SCRIPT"? During my script I call another script that is first copy into /usr/local/bin In the unraid WEBUI Shell, If I run ./monitor_arrayAudioChanges.sh I am returned to the # prompt and the process runs in background fine. If I close the RUN SCRIPT window the PID started by the monitor_arrayAudioChanges.sh is also terminated. I have tried sever suggestions I found online to have this .sh start in a different way / in background but have had no luck. Any suggestions? ## Install inotify-tools package ## installpkg /boot/packages/inotify-tools-3.22.6.0-x86_64-1.txz ## Setup monitoring of music and audiobooks array folders ## cp -r /boot/custom/audioArrayToSSD /usr/local/bin && chmod +x /usr/local/bin/audioArrayToSSD/sync_arrayAudioToSSD.sh && chmod +x /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh source /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh ## Install docker compose BLABLABLA Chasing some feedback on this one please if anyone knows what I can do. Quote Link to comment
BlackMamba24 Posted April 6 Share Posted April 6 (edited) Hello, I came across this plugin to remove the .DS_store files. I also have issues with needing to remove ._.DS_Store files as well as ._filename that mimics my actual file but tiny size (I believe its a mac related file and that "_.*" would remove them. Can anyone check if the script I have below is correct for removing the two additional types of files? #!/bin/bash echo "Searching for (and deleting) ._.DS_Store Files in array and external backup drives" echo "This may take a awhile" find /mnt/user -maxdepth 9999 -noleaf -type f -name "._.DS_Store" -exec rm "{}" \; find /mnt/disks -maxdepth 9999 -noleaf -type f -name "._.DS_Store" -exec rm "{}" \; #!/bin/bash echo "Searching for (and deleting) ._* Files" echo "This may take a awhile" find /mnt/user -maxdepth 9999 -noleaf -type f -name "._*" -exec rm "{}" \; find /mnt/disks -maxdepth 9999 -noleaf -type f -name "._*" -exec rm "{}" \; Also, is it ok to run a second script that targets my external drive in the same script like above? Very new to unraid so any help is much appreciated, thank you! Edited April 6 by BlackMamba24 Quote Link to comment
Nano Posted April 9 Share Posted April 9 I have an issue where the scripts always say "schedule disabled" I can try to change to any option eat, apply refresh done. ITS always Schedule disabled. Quote Link to comment
Squid Posted April 9 Author Share Posted April 9 Flash drive read only??? Also any weird punctuation etc in the script names? Quote Link to comment
Nano Posted April 10 Share Posted April 10 (edited) On 4/9/2023 at 12:56 PM, Squid said: Flash drive read only??? Also any weird punctuation etc in the script names? Is there a good way to check if its read only? Edit : This was resolved by manually deleting user scripts folder and files within the Flash drive and reinstalling fresh. Edited April 10 by Nano Quote Link to comment
olco Posted April 30 Share Posted April 30 I would like to run a script after the server is started. Can I achieve this by adding "@reboot" under crontab? Because this does not work for me. Furthermore, the script should also start a Docker container. Are the permissions sufficient for this? Currently it seems that the script does not start after restarting the server. If I run it manually in the background, then a part is processed, but the Docker container does not start. When I run it a second time, the Docker container also starts. Quote Link to comment
Hoopster Posted May 2 Share Posted May 2 On 4/30/2023 at 4:19 PM, olco said: I would like to run a script after the server is started Will the Users Scripts option "At Startup of Array" work for this if you have the array set to autostart on a server boot? As to starting the docker container, I don't have any thoughts on that. Quote Link to comment
olco Posted May 3 Share Posted May 3 So now I chose the "At Startup of Array" as start option for the script. The script creates the two folders, which get removed everytime I reboot the server, but it doesn't mount the rclone remote and it doesn't start the embyserver docker. When I abort the script and manually run it again, one time, the remote gets mounted and embyserver docker starts. It doesn't seem like a complex script to me ;) #!/bin/bash sleep 60 mkdir /mnt/gsuite sleep 5 mkdir /mnt/gsuite/media sleep 5 rclone mount gsuitemedia:/Medien /mnt/gsuite/media --allow-other --buffer-size 100M --dir-cache-time 72h --drive-chunk-size 32M --umask 002 --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit off --read-only sleep 10 docker container start EmbyServer Quote Link to comment
SimonF Posted May 3 Share Posted May 3 5 minutes ago, olco said: So now I chose the "At Startup of Array" as start option for the script. The script creates the two folders, which get removed everytime I reboot the server, but it doesn't mount the rclone remote and it doesn't start the embyserver docker. When I abort the script and manually run it again, one time, the remote gets mounted and embyserver docker starts. It doesn't seem like a complex script to me #!/bin/bash sleep 60 mkdir /mnt/gsuite sleep 5 mkdir /mnt/gsuite/media sleep 5 rclone mount gsuitemedia:/Medien /mnt/gsuite/media --allow-other --buffer-size 100M --dir-cache-time 72h --drive-chunk-size 32M --umask 002 --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit off --read-only sleep 10 docker container start EmbyServer its one of the schedule options. Quote Link to comment
kouru225 Posted May 5 Share Posted May 5 (edited) One of my scripts recently stopped working and I'm not sure why. It's an amateur bash script I wrote a while ago that reformats some files and moves them. The second for loop has just stopped working for some reason. It doesn't ever echo anything. The first one does just fine... I've been using this same script for almost 2 years now... EDIT: I figured it out. I was being stupid. I had all these text files reformatted to .md files and then didn't change the for loop. #!/bin/bash folder="/mnt/cache/Real_Dropbox/Apps/Otter/Voice_Memos_New" if [[ -z "$(ls -A -- "$folder")" ]] ; then echo "$folder is empty" else echo "$folder is not-empty and contains $(ls $folder)" cd $folder for file2 in *; do if echo "$file2" | grep -q '\s'; then echo "File title contains spaces" mv "$file2" `echo $file2 | tr ' ' '_'`; echo "changed $file2 to underscores"; else echo "File title does not contain spaces" fi done for file in $(find $folder -name '*.txt'); do filename=$(basename -s .txt $file); echo "stored filename $filename"; audio=$filename.m4a; echo "identified audio file $audio"; time_created=$(stat -c %y $audio|tr ' ' '_'|sed 's/-//g; s/://g; s/\.[^\.]*$/_/'); yamldate_created=$(stat -c %y $audio); echo "stored time created $time_created"; newaudio=$time_created$audio; echo "added time created to audio name $newaudio"; newtranscription=$time_created$filename.md; echo "added time created to transcription name $newtranscription"; mv $file $newtranscription; echo "changed $file to $newtranscription"; mv $audio $newaudio; echo "changed $audio to $newaudio"; sed -i "1i \#\# Transcript" "$newtranscription"; sed -i "1i \!\[\[$newaudio\]\]" "$newtranscription"; sed -i "1i \-\-\-" "$newtranscription"; sed -i "1i date\:\ $yamldate_created" "$newtranscription"; sed -i "1i tags\:\ primarysource" "$newtranscription"; sed -i "1i type\:\ primary\ source" "$newtranscription"; sed -i "1i \-\-\-" "$newtranscription"; echo "added formatting to transcription $newtranscription"; mv $newtranscription /mnt/user/Syncthing/The\ Galactic\ Mining\ Operation/My\ Media/File\ Notes/Primary\ Sources\ \(Transcripts\)/; echo "moved $newtranscription to syncthing"; mv $newaudio /mnt/user/Syncthing/The\ Galactic\ Mining\ Operation/Media/My\ Files/My\ Audio\ Files/Transcribed\ and\ Connected/; echo "moved $newaudio to syncthing"; done fi Edited May 5 by kouru225 Quote Link to comment
ramiro Posted May 10 Share Posted May 10 Has anybody else the problem that scripts with custom quene are not added to the /etc/cron.d/root file after a reboot ? I have to change something in the scripts and after i click apply they are back in the file. Quote Link to comment
goa200 Posted May 11 Share Posted May 11 I've searched the forums for a script that pings an ip and if it doesnt respond it starts a docker. If anyone has such a script or can point me in the right direction id be immensly thankful.I've searched the forums for a script that pings an ip and if it doesnt respond it starts a docker. If anyone has such a script or can point me in the right direction id be immensly thankful. Quote Link to comment
JonathanM Posted May 11 Share Posted May 11 8 hours ago, goa200 said: I've searched the forums for a script that pings an ip and if it doesnt respond it starts a docker. If anyone has such a script or can point me in the right direction id be immensly thankful.I've searched the forums for a script that pings an ip and if it doesnt respond it starts a docker. If anyone has such a script or can point me in the right direction id be immensly thankful. You will have to rewrite this to do what you want, but I think the basic concept is there for you. This script pings an IP, waits until it responds, then runs a command. If you research the ping command you should be able to use the logic the way you want. #!/bin/bash printf "%s" "waiting for IP to respond ..." while ! ping -c 1 -n -w 1 192.168.1.1 &> /dev/null do printf "%c" "." done printf "\n%s\n" "IP is responding" docker start "Container" Quote Link to comment
goa200 Posted May 11 Share Posted May 11 23 minutes ago, JonathanM said: You will have to rewrite this to do what you want, but I think the basic concept is there for you. This script pings an IP, waits until it responds, then runs a command. If you research the ping command you should be able to use the logic the way you want. #!/bin/bash printf "%s" "waiting for IP to respond ..." while ! ping -c 1 -n -w 1 192.168.1.1 &> /dev/null do printf "%c" "." done printf "\n%s\n" "IP is responding" docker start "Container" Thx. I do however wanna do the opposite i.e. if the ip isnt responding then i wanna start a docker. Doing some sort of plex backup where i have 2 servers in diff location and if one goes down i wanna start the other plexdocker Quote Link to comment
JonathanM Posted May 11 Share Posted May 11 1 hour ago, goa200 said: I do however wanna do the opposite So change it to do what you want. That's the point of my post, here are the building blocks, assemble as needed. Quote Link to comment
goa200 Posted May 11 Share Posted May 11 1 hour ago, JonathanM said: So change it to do what you want. That's the point of my post, here are the building blocks, assemble as needed. Yup Thx to your script i manage to come up with a version of my own. Big Thx for pointing me in the right dir. Quote Link to comment
HHUBS Posted May 12 Share Posted May 12 How to run a script after all of the docker is started? (Not at the start of array) Quote Link to comment
adgilcan Posted May 12 Share Posted May 12 I've forgotten how to order the script list to my preferences. Can anyone help me out? Many thanks D Quote Link to comment
adgilcan Posted May 12 Share Posted May 12 I think I solved it and post it here for others. The order displayed is defined by the order of the folders in config/plugins/user.scripts/scripts It appears you can rename these without having to alter the name of the script in User Scripts. At least that seems to work for me. I hope that helps D Quote Link to comment
srirams Posted May 12 Share Posted May 12 On 5/10/2023 at 3:11 PM, ramiro said: Has anybody else the problem that scripts with custom quene are not added to the /etc/cron.d/root file after a reboot ? I have to change something in the scripts and after i click apply they are back in the file. I have the same problem.... 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.