I am trying good 6 hours get speedtest running.
I can execute command speedtest and /usr/bin/speedtest via ssh:
Same command seems not to work inside rules:
val speedtestExecute = “/usr/bin/speedtest@@–accept-license@@–accept-gdpr@@-f@@json”
var speedtestCliOutput = executeCommandLine(speedtestExecute, 120*1000)
Here is the log:
It looks like openhab’s execUtil can’t see the file.
I am able to run the command on behalf of openhab user:
openhab:openhab is owner of speedtest file located inside /usr/bin/ directory.
I am running openhab using docker on openhab:openhab user. User is owner of /opt/openhab files.
I was reading so many topic on the forum, but haven’t find the answer.
Any ideas? Maybe the problem is that openhab is located inside docker container?
Thanks in advance
executeCommandLine has no shell environment. Sometimes people put commands into shell scripts and execute the scripts.
I don’t know if you are aware of this feature. But if you use the network binding, you can use a already existing feature “speed Test” as an own thing. So no need to write a script for this
I tried to run it within scripts/demo.sh without much success. I saw different tutorials for Speedtest i to openhab and it was working for other people, but maybe because I use docker and other people dont?
However thanks for answer. I will look into that topic.
Oh I wasnt aware of that. Definitely I will check this out. However it would be great to know what is the issue.
The same errors? Different errors?
If those are the output of running the command as user openhab it didn’t work. There are “permission denied” errors on /home/openhab/.config (wonder why it’s writing there, openHAB’s home directory should be /var/lib/openhab2).
I suspect the two errors are related.
Same errors trying to run .sh:
2020-12-01 17:50:23.140 [WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program “/opt/openhab/conf/scripts/demo.sh” (in directory “.”): error=2, No such file or directory)
Permission denied comes from I believe the fact that the home directory doesn’t even exist for openhab user. As Docker openhab’s documentation says: "
So first create an openhab user configured to be a system user with no home and no shell(…)
I believe that: user’s home directory by default should be /home/openhab so that’s probably why it tries to save that there. but directory for my openhab platform is /opt/openhab since I am using docker (at least config files are there). I don’t have such directory like /var/lib/openhab2.
That is why it is better to say
userdata. Your equivalent is likely
Actually, it needs to be the path inside the container which would be /openhab/userdata I think.
On the host it very well may be /opt/openhab/userdata but openHAB inside the container wouldn’t see that path.
@Bartlomiej_Marek, I totally missed the fact that you are running in Docker. Have you created a custom Image that includes speedtest-cli? The whole point of containers is that they cannot see anything that is on the host unless you explicitly give it permission. That totally explains the error now. speedtest-cli doesn’t exist inside the container.
You have to do one of the following:
- create a custom Image that include speedtest-cli
- create some script outside of openHAB that openHAB can communicate with over the network (even if it’s running on the same machine, MQTT or HTTP are good choices) that can run the script on command
- install openHAB on the host instead of running it in a container
Your tests from running it on the command line with sudo are irrelevant. You would need to run those commands from inside the container which is challenging because
sudo doesn’t exist inside the container either I don’t think.
So @rlkoshak is right with his guess. There is no sudo inside the docker container. If you access the docker container you will be root and don’t need sudo as command. But from my understanding openhab is not running as the root user inside the docker container so maybe to run as the openhab user you will need to ad sudo again.
But anyway, as mentioned by @rlkoshak the docker container does not include the speedtest-cli. You need to add this manually. But be care ful, if you add this manually, you will loose the component with the next openhab docker update. So whenever you update the docker image you need to install the speedtest-cli again. Therefore you should either create a second docker for this purpose and configure the speedtest-cli in this one. Then call the docker from the other one and this should work. So you will not loose the configuration on a docker update.
You should think about this approach because you will need some technical knowhow to get this working. The difficult here is to allow the communication of both docker containers wich can be difficult if the openhab container runs on the host network and not inside the docker network. (I assume you choosed this because this is the easiest setup)
So thinking about all these facts I think the easiests way is to use the network binding because this will not have any side efects on an openhab update (expecting that the binding itself is still working and has no bug on the new version of OH)
You totally nailed it.
I will try first option first if that won’t work I will for sure try installing openHAB on the host instead running it inside container.
su would work but it’s hard to do one liners with
su. The entryPoint script that starts up openHAB inside the container su’s to the passed in UID in the environment variables before starting OH.
Today I migrated dockerized version to the one hosted on linux.
I was able to:
- setup git repository
- copy /conf files into /etc/openhab2
- setup samba share
& many more
I spent maybe like 15mins to get speedtest running. Here is output from that:
@rlkoshak Everything was so easy, but I was expecting that I would have to copy: habpanel.config to my new userdata. I haven’t done that and my UI is working. I have no idea how it was migrated, but habpanel is working flawlessly.
Thanks one more time
You probably saved it locally instead of on the server. Look in the HABPanel settings and you will see that you can set where the config is saved. This lets you have a different panel config for each of your devices.
When saved on the server, the config is saved to /var/lib/openhab2/config.