I’m currently researching on what the best way is to deploy my app on Balena OS.
What important is for my code is that the 4G connection is always enabled before starting docker images. What I do is execute bash commands that communicate with ttyAMA0 and send AT commands. After that I use libqmi-utils to activate an wwan0 connection for direct 4G internet.
This code must be running no matter what. Normally this bash command is added to /etc/rc.local. I’ve discovered that I cannot sudo and modify outside the docker containers.
I was wondering what the best option for me is to be sure that the bash app is running no matter what? And is executed before the containers are activated?
Hi,
Unfortunately it is not possible today to run custom code in the underlying hostOS. We have a feature called host apps that will allow for this, this is planned for somewhere mid next year.
But maybe we can go around your need to run code on the hostOS, could you explain in a bit more detail why you need to enable the 4G connection before any containers run?
Kind regards,
Theodor
Thank you for your answer. I want it to connect just like a regular wifi connection. If I deploy this inside an container, and something goes wrong, the device cannot communicate with the balena server anymore and the container cannot be reverted back to an old one.
Thanks for the additional info. Indeed as telphan answered, its not yet possible but there is active work on a feature we call “hostApps” where one will be able to add functionality to the OS, but today its not possible. You can track it here: https://trello.com/c/2CjPzxJ0/11-hostapp but hopefully we will add more colour to that over the coming months.
I have the same exact problem. I need to integrate an LTE modem that does not seem to have a documented method of configuration through system-connections. I see that the hostapp feature is in the committed column but what does that actually mean? And is there really no way to configure scripts that should run before the Docker process?
Just a simple question and potential workaround while hostApps are not a thing yet.
Can’t you just integrate the script into your image?
I had something similar with a difficult 4G modem, where I simply ran a script that periodically checked if it was up and running and if not restarted it.
In my applications I generally assume I can get disconnected at any time.
Something like
#!/bin/sh
# background script to make sure modem is connected
/usr/src/app/check_modem.sh &
check_pid = $!
# optionally wait for initial connection
while [ ! /usr/src/app/check_connected.sh ]; do
sleep 1s
done
# actual application
/usr/src/app/run_application.sh
# optionally shutdown modem script when we're done
kill $check_pid
The only real downside of this is a bootstrapping issue when your image doesn’t run properly and therefore never configures the modem properly.
For my devices, I usually do first boot while connected by ethernet.
I have to do some manual configuration for my applications, so it makes sense to me to have the stable/fast connection while tweaking things.
I understand that what works for me, doesn’t necessarily go for everyone.
As I was responding to a raspberry pi question, I was assuming ethernet would be an option while provisioning.
Yes, it’s a difficult task to keep connection stable for long periods of time. There are several steps I do through mmcli and through a modemanager bus.