docker-ha-bridge icon indicating copy to clipboard operation
docker-ha-bridge copied to clipboard

Can't run any scripts

Open abtzero opened this issue 7 years ago • 11 comments

ha-bridge 4.5.0 runs on my synology via docker. Everything works fine, but I can't get any exec-command to work. Most of the times I get a "file not found" error. Tried everything I can imagine. I get a green response in the ha-bridge interface but nothing is executed by using for example: /usr/bin/python3 /volume1/Data/haactions/py/aquosOFF.py The same for shell scripts. I guess, it is a question of user-rights. Am I right, that everything is executed by root (how can I find out?), but on the synology the user root has limited rights? How could I get around this?

abtzero avatar May 16 '17 10:05 abtzero

The container only has access to locations that are mounted in the docker run command. By default, the config folder is mounted under /config

You need to use the internal maooed location of the script (and first make sure that location is mounted)

aptalca avatar May 16 '17 12:05 aptalca

Thanks for Your response! I added a mounted path to the existing folder /docker using the docker gui and setting the folder to /docker and mount-path to /docker (correct?). Added a simple python script into the subfolder "py" and added the command /usr/bin/python3 /docker/py/test.py into ha-bridge. It works manually with my user in a console but not with ha-bridge. What else do I need to do?

abtzero avatar May 16 '17 16:05 abtzero

I added a mounted path to the existing folder /docker using the docker gui and setting the folder to /docker and mount-path to /docker (correct?) I don't quite understand this statement but I'm assuming that on the host, the script is at /docker/py/test.py, in the docker run command you used -v /docker:/docker:rw and in the bridge you are using the location /docker/py/test.py If so, that seems to be correct. As to why the script isn't firing, you should ask on bwssystems' github. I don't have any experience with firing python scripts from this bridge.

aptalca avatar May 16 '17 16:05 aptalca

Well, I do not know how to manipulate the RUN command (I do not know where to put the -v /docker:/docker:rw I am working on the synology's gui to do that: image And in ha-bridge: image I think, it should work having access to my added directory. Firing up a shel script with it's name does not give me an 'file not found' - error anymore. But does not work. (my test-script should write a file to my directory.) Can I expect having access to all system programs (i.e. bash and python modules) root would have, without mounting any additional path?

EDIT: I got a python script working now, which writes a text-output to my directory. My script that should turn on/off my sharp-TV is still not working (could be something with the import socket command...) But thanks man! You pushed me into the right direction by telling me to add a mounted path.

abtzero avatar May 16 '17 16:05 abtzero

Good to hear that python works. Just so you know, the script will only have access to the libraries and modules inside the container, which is ubuntu.

If you want to test/troubleshoot your python script, it is best to do inside the container so you can see the console output. You can exec into the container with docker exec -it <containername> bash from synology console.

aptalca avatar May 16 '17 17:05 aptalca

Thanks for this hint! When I connect as admin via SSH the command docker exec -it aptalca-home-automation-bridge1 /bin/usr/python3 /docker/aquosON.py gives me the response Cannot connect to the Docker daemon. Is the docker daemon running on this host? Wrong user?

abtzero avatar May 16 '17 17:05 abtzero

maybe try with sudo ?

aptalca avatar May 16 '17 17:05 aptalca

Yes, but then it doesn't find python3. It is not the same environment, as executed by ha-bridge.

abtzero avatar May 16 '17 17:05 abtzero

/usr/bin/python3

or just python3

aptalca avatar May 16 '17 17:05 aptalca

OMG, sure ist has to be /usr/bin/ Now I have a script error output. Thanks again!

abtzero avatar May 16 '17 17:05 abtzero

YESSS! For all readers in the background: Firing up python scripts worked now, but my script, that should turn ON/OFF my Sharp Aquos TV failed with the error message: TypeError: 'str' does not support the buffer interface This is caused by using a socket send command like s.send(user + "\r" + password + "\r"). With python 3 this should be s.send((user + "\r" + password + "\r").encode()) That way it works.

Buuuut: My Sharp TV looses IP-connection after being more than 10 minutes in standby... lol

abtzero avatar May 16 '17 18:05 abtzero