Tried some more and used the absolute paths from root up to the files and adding an error output to a file (2> /config/command.log), no luck.
As you can see in the screenshot of the SSH Terminal, manually executing the script still works OK. Both from SSH landing location (~) and up to root (/) (e.g. not the /root directory).
When calling the service (using the exact same shell_command) from within HASSIO, the command.log error output file shows:
/bin/bash: /root/config/dropbox_uploader.sh: No such file or directory
BTW, both script and config files are also in the /config directory (the screenshot shows them in the ~ directory. Before someone smart mentions the path is wrong…
It also should be run using /bin/bash, see the shebang in the script : #!/usr/bin/env bash
Couple things…why do you run it as root? Not sure if hass.io works differently than Rasbian or Ubuntu but…
this works for me on both environments (the last two). I have the whole Dropbox-Uploader directory in /home/homeassistant
It is a HASS.IO thing, mapping and setup of directories is not like the normal home assistant. For instance, the /www directory is only reachable as /local.
We do not have a ‘home’ folder. You only can access it as root.
And because that is a mapping I am sure of exists, I have tested putting the script files in there and use the path to that directory as well, but no luck either.
Thanks for your suggestions though.
According to Portainer (to manage Docker containers), the mapping of the homeassistant container is:
Host/volume
Path in container
/usr/share/hassio/homeassistant
/config
/usr/share/hassio/ssl
/ssl
/usr/share/hassio/share
/share
Of course I tested this path now I found it…
But, you guessed it probably by now, result:
/bin/sh: /usr/share/hassio/homeassistant/dropbox_uploader.sh: not found
Maybe I need to SSH to the host to be able to run the shell_command?
hey, did you ever figure it out? i also have those errors 1 and 127 , running from ssh works though
also running hassos here , struggling with paths also, i dont know why it works from ssh, but not from a service
Hi Fabio. No, I have since then moved to another solution for backup (Google Drive) running on a different hardware/OS setup altlogether. Never had the need to run scripts since.
yeah, is strange, my other bash scrips are working this one not , my guess is that i am using an “apk add” command, it doesnt like it i think, maybe needs sudo access
Theres a pretty limited set of commands you can use. It will be running in the Home Assistant container when you run a shell command. If you open a console in that container and try and run the script you will see what is causing the problem.
the file is created, so that means all yaml code is good! also shell command is fired
when the bash script is like below , i receive error 1 or error 127
if i do the same apk command or the same /bin/bash /config/bash.sh from PUTTY/SSH it also works
so my guess its the HA user doesnt have the right to use the APK ADD command
Ok, i know why, i just need to point another release, seems there is a different version for Alpine edge and Alpine 3.13 and HA doesn’t allow community packages
Yeah, problem is that I’d you run it from a script, it actually fires in the HA container, and you don’t see the output… In the ssh addon, the command worked for me, but not in script, so I that I did, within the ssh addon, I do the docker command to enter the HA container, from there I do the command again, to see what error 127 was, so that’s how I resolved it…
In my case I was installing an APK alpine package, but the HA container was not able to find the repository for that specific APK, seems that container was another alpine version then the SSH container, so I pointed the APK file manually
OH! totally forgot that they’re two different containers out of the habit of working always on the same machine, lol. I’ve installed sshpass in the addon and not HA container.