alturismo Posted November 19, 2017 Share Posted November 19, 2017 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 Quote Link to comment
LSL1337 Posted November 19, 2017 Share Posted November 19, 2017 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! Quote Link to comment
alturismo Posted December 4, 2017 Share Posted December 4, 2017 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 Quote Link to comment
itimpi Posted December 4, 2017 Share Posted December 4, 2017 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. Quote Link to comment
alturismo Posted December 4, 2017 Share Posted December 4, 2017 (edited) 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 December 4, 2017 by alturismo Quote Link to comment
itimpi Posted December 4, 2017 Share Posted December 4, 2017 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. Quote Link to comment
alturismo Posted December 4, 2017 Share Posted December 4, 2017 (edited) 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 December 5, 2017 by alturismo Quote Link to comment
johnieutah Posted December 5, 2017 Share Posted December 5, 2017 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 Quote Link to comment
Squid Posted December 5, 2017 Author Share Posted December 5, 2017 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 Quote Link to comment
xhaloz Posted December 10, 2017 Share Posted December 10, 2017 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? Quote Link to comment
Squid Posted December 10, 2017 Author Share Posted December 10, 2017 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 Quote Link to comment
iamtpage Posted December 13, 2017 Share Posted December 13, 2017 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? Quote Link to comment
Squid Posted December 13, 2017 Author Share Posted December 13, 2017 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 Quote Link to comment
DZMM Posted December 19, 2017 Share Posted December 19, 2017 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 Quote Link to comment
BRiT Posted December 19, 2017 Share Posted December 19, 2017 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 1 Quote Link to comment
DZMM Posted December 19, 2017 Share Posted December 19, 2017 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 Quote Link to comment
publicENEMY Posted December 26, 2017 Share Posted December 26, 2017 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. Quote Link to comment
Squid Posted December 26, 2017 Author Share Posted December 26, 2017 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. Quote Link to comment
Marcel40625 Posted January 5, 2018 Share Posted January 5, 2018 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? Quote Link to comment
trurl Posted January 5, 2018 Share Posted January 5, 2018 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? Quote Link to comment
Marcel40625 Posted January 7, 2018 Share Posted January 7, 2018 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? Quote Link to comment
bonienl Posted January 7, 2018 Share Posted January 7, 2018 (edited) 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 January 7, 2018 by bonienl Quote Link to comment
pwm Posted January 7, 2018 Share Posted January 7, 2018 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. Quote Link to comment
bonienl Posted January 7, 2018 Share Posted January 7, 2018 (edited) 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 January 7, 2018 by bonienl Quote Link to comment
pwm Posted January 7, 2018 Share Posted January 7, 2018 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> 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.