Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Plugin] CA User Scripts

Featured Replies

5 hours ago, Squid said:

Because executing bash within a container by default means that its interactive, and the system is effectively waiting for you to enter in the commands

Try this


docker exec -t apache Step 0
docker exec -t apache Step 1
docker exec -t apache Step 2

 

 

great hint, 1 step further, thanks alot ;)

  • Replies 2.1k
  • Views 567.2k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • 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

  • Hi All - We have a fix and are publishing a Connect plugin update to fix it today. Thanks for letting us know.

  • @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 2017. 11. 18. at 2:20 PM, Squid said:

Without thinking too much:

 


#!/bin/bash
hdparm -C /dev/sdb >> /mnt/user/sharename/status.txt  #change path to suit
smartctl -a /dev/sdb | grep Temperature >> /mnt/user/sharename/status.txt
#repeat for more disks

sensors | grep Fan >> /mnt/user/sharename/status.txt

And running at whatever schedule you choose.

Thank you very much!

  • 2 weeks later...

hi again, may another question about exec

 

i get an cannot exec binary error when trying to copy ...

docker exec -t apache bash ./bin/cp /etc/letsencrypt/live/mydomain.de/*.pem /config/keys
./bin/cp: ./bin/cp: cannot execute binary file
 

while this command working fine

docker exec -t apache bash ./config/certbot/certbot-auto -n --config /config/certbot/cli.ini certonly

 

may an idea what this cannot access binary could mean ? inside docker it works as expected ...

for an tip, thanks ahead ;)

The leading ‘.’ on the commands will make them relative to a home folder.   For ‘cp’ this will not work as you need an absolute path to the binary.

8 minutes ago, itimpi said:

The leading ‘.’ on the commands will make them relative to a home folder.   For ‘cp’ this will not work as you need an absolute path to the binary.

 

same result, also tested it without the ".", forgot to mention ;)

 

root@AlsServer:~# docker exec -t apache bash /bin/cp /etc/letsencrypt/live/mydomain.de/*.pem /config/keys
/bin/cp: /bin/cp: cannot execute binary file

Edited by alturismo

3 minutes ago, alturismo said:

 

same result, also tested it without the .

 

root@AlsServer:~# docker exec -t apache bash /bin/cp /etc/letsencrypt/live/mydomain.de/*.pem /config/keys
/bin/cp: /bin/cp: cannot execute binary file
 

That probably means that the ‘cp’ command is not located in /bin inside the container.     You could try omitting the /bin part to use the search path, or instead try using /user/bin in case that is where it is located.

hmm

 

root@AlsServer:~# docker exec -ti apache bash
root@AlsServer:/# ls
app  boot    defaults  etc   lib    media  opt   root  sbin  sys  usr  webdav
bin  config  dev       home  lib64  mnt    proc  run   srv   tmp  var
root@AlsServer:/# cd bin
root@AlsServer:/bin# ls -la
total 6532
...
-rwxr-xr-x 1 root root  130304 Mar 10  2016 cp

....

may i miss something ?

 

EDIT, its been symlinked files ... that was the reason, docker cp -L ... seems to work, thanks again

Edited by alturismo

Any ideas about this log snippet I keep getting emailed to me for some reason??

 

Subject: 

cron for user root /usr/bin/run-parts /etc/cron.hourly 1> /dev/null

 

Body:

/etc/cron.hourly/user.script.start.hourly.sh: line 2: 39834 Bus error               /usr/local/emhttp/plugins/user.scripts/startSchedule.php hourly

  • Author

Bus errors are when the system tries to execute a command on an odd memory address.  Ultimately this is a bug in PHP / Linux Kernel as its impossible for a script to do this.  You can try running a memtest to rule that out, but it happens maybe once every couple of months on my AMD system for absolutely zero reason.

 

IE: ignore it 

Hello,

 

I love this plugin.  I did have a question....whenver I had cron tabs running via /boot/config/plugins/dynamix/ I got an email after each cron task was completed.  When I run the same job via this GUI, I do not get an email alert with success or fail.  Any ideas?

  • Author
Hello,

 

I love this plugin.  I did have a question....whenver I had cron tabs running via /boot/config/plugins/dynamix/ I got an email after each cron task was completed.  When I run the same job via this GUI, I do not get an email alert with success or fail.  Any ideas?

Because this plugin doesn't directly execute any script. It calls a proxy which then executes the script. Net result is that you will never see an email from cron that the return code from your script was non zero. Any notifications you want from your script you will have to do via the notify commabd

 

And via basically adding the cron entry yourself as you were you were getting an email that your script returned a non zero return value (ie that it failed or had an error) return values of zero (success) don't send an email

Hi,

 

I have scripts that I want to run when I'm not home. I can track my presence using my HomeAssistant setup, however the execution of the script is what I'm stuck on. I tried HTTP POST'ing the URL, but it looks like the script execution buttons are in JS, which won't work for cURL requests.

 

My next attempt would be having a script SSH into the unRAID server and kickoff the script over SSH. Is there an easier way to do this?

  • Author

The execution order is

 

Button (JavaScript) -> Wrapper (PHP) -> Actual Script (whatever interpreter you choose)

or via a scheduled script,

Wrapper (PHP) -> Actual Script

 

The actual scripts are scripts as in something you would run from the command line (ie: bash, PHP, python, etc)

 

Nothing is stopping you from using curl in bash or in PHP.  You could probably do it via JavaScript by installing nodejs via the NerdPack

 

This is all for background tasks.  You can however run JavaScript & any HTML via a foreground script.  See that PacMan additional script

Can I get some help with what should be a simple script please for someone who unlike me, knows what they are doing.

 

I run a pfSense VM which means my bootup is very slow as unRAID starts docker before VMs and each docker checks for online access before the next one starts - all in all this adds a 20--30min delay before my server boots.

 

As a temp fix, what I've started doing is disable Docker in unraid's settings before rebooting and then manually turning docker on once the pfSense VM provides connectivity.

 

What I'd like to do is add a script that runs at array start and manually starts Docker once it successfully pings 172.30.12.1 which is the address of my pfSense VM - similar to how the docker autostart manager does i.e. check if can ping 172.30.12.1, if yes, start docker, if fails after say 10 mins (customisable would be nice) then start docker anyway

 

If someone can help me with this script (I know how to start individual dockers via the command line, but not the whole docker manager).  I'll copy the script to make another one to stop docker when the array stops.

 

Thanks in advance

This isn't entirely what you're looking for but here's tidbits that I'm just throwing stuff out there...

 

If you can't work out the ping and network connectivity testing you could schedule a script to start docker 10 minutes after bootup.

 


echo /etc/rc.d/rc.docker start | at now + 10 min

 

To control docker from a whole you can use /etc/rc.d/rc.docker. That script has the following parameters:

  • start
  • stop
  • restart
  • status
49 minutes ago, BRiT said:

This isn't entirely what you're looking for but here's tidbits that I'm just throwing stuff out there...

 

If you can't work out the ping and network connectivity testing you could schedule a script to start docker 10 minutes after bootup.

 

 


echo /etc/rc.d/rc.docker start | at now + 10 min

 

 

To control docker from a whole you can use /etc/rc.d/rc.docker. That script has the following parameters:

  • start
  • stop
  • restart
  • status

Thanks so far, I've got:

 

#!/bin/bash

echo /etc/rc.d/rc.docker stop
echo /etc/rc.d/rc.docker start | at now + 10 min
docker restart $(docker ps -a -q)

Line 1 is so I can leave settings\Docker 'Enable Docker' set to 'yes'.  I think I need this as otherwise I won't have the dockers tab in the GUI.  My thinking is:

 

- step 1, stop the dockers

- step 2 start  docker again in 10 mins (and re-populate the Docker tab in the GUI)

- step 3 start all containers - the command you shared didn't start the containers

 

If I can't get the ping test working I'll just go with this and if I'm at the keyboard I'll start the dockers quicker manually.

 

 

 

 

seems to stop the dockers (actually hides them from the GUI) but leaves the empty Docker tab visible

I have the script running plexdrive in the background. But when I stop the script, i can see that plexdrive is still running. If I run plexdrive in console, then close the console(putty), plexdrive stopped running.

 

What can i do to make that when i stop the script, things inside the script stop running?

 

Thanks.

  • Author

Generally, any commands / scripts spawned will run to completion.  The plugin does try and do what it can to kill any processes spawned by the lead script (pkill -TERM -P pid), but depending upon what actually got spawned, it doesn't always work.

  • 2 weeks later...

Hey Guys. im using a rsync script with this plugin, is there a way to send the log of the script as an notification to my email set in the notification settings?

4 hours ago, Marcel40625 said:

Hey Guys. im using a rsync script with this plugin, is there a way to send the log of the script as an notification to my email set in the notification settings?

 

On 5.1.2018 at 1:40 PM, trurl said:

 

 

Yeah thanks i already saw that ... but my question is how do i attach the log to the mail?

You can do something like

/usr/local/emhttp/webGui/scripts/notify -e "rsync log" -m "$(cat /tmp/logfile.txt)" -i "warning"

This is a bash example and assumes the log file of rsync is /tmp/logfile.txt which is included using the -m option (don't forget the quotes).

Edited by bonienl

22 minutes ago, bonienl said:

You can do something like


/usr/local/emhttp/webGui/scripts/notify -e "rsync log" -m "$(cat /tmp/logfile.txt)" -i "warning"

This is a bash example and assumes the log file of rsync is /tmp/logfile.txt which is included using the -m option (don't forget the quotes).

It just important to note that the above assumes that the logfile doesn't contain any " characters - or that any " characters have been preprocessed with a break character like \"

 

It is extra important to realize that if someone can manipulate the logfile.txt contents, the above construct could allow a second (and most probably quite evil) command to be run directly after the notify command. What a joy it would be with a logfile.txt that contains

Bye, bye..."; rm -rf /mnt/disk*; echo " ...array data


Best would be if the notify script supported an alternative form that takes a filename instead of a direct string.

If the log file is not just plain text but has "special" characters then bash isn't the right language to call notify. A language like PHP allows you to escape special characters, including quotes. This has been done for the GUI to avoid the potential risk of executing commands as explained by pwm.

 

Edited by bonienl

If notify can't handle a file name, then I would suggest to write a tiny php script that opens the file, massages the content and then prints the result.

 

And then replace

cat <filename>

with

/usr/bin/php safe-filter.php <filename>

 

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.