Executing commands on host

I need to be able to execute a small script on the host before the container/application is started or restarted.

I need this to initialise bluetooth correctly. I have tried the commands from inside the application container without success… If I execute them manually from a host terminal and restart the application container then all is golden.

The commands are

   - hciconfig  hci0 up/down
   - bluetoothctl <<< connect <MAC ADDR>

Which resinOS version (and which device) are you using?

Resin OS 2.12.0+rev1 (prod)
FROM arm32v7/ubuntu:artful

(for RPi)

I believe that you should be able to see the device interfaces from within the container. Are you running those commands in the host OS because you do not see the hci interface inside your container?

If I run the commands in the container, I get errors including ‘failed to connect’.

If I manually execute on the Host OS, and restart the container all is good.

Here is the script:


bluetoothctl << EOF

scan on

disconnect ${NORDIC_ADDR}



hciconfig hci0 down

hciconfig hci0 up

bluetoothctl << EOF

scan on

connect ${NORDIC_ADDR}



The hci0 device is visible.

NOTE - this only happens when I provision a new device.

The script above only has to be executed once on the Host OS.

After that I can execute it inside the container and it works - probably because I only need to do it once for a device.


so to answer your previous question. Today it is not possible to execute commands or scripts in the HostOS before the container starts. But in the future we’ll have a feature called “hostapps” which will allow users to modify the host OS like they modify their application.

Now, regarding the bluetooth, I see that you are not using a resin base image, which could be the issue here.
So, can you try using our debian image and see if you still have the same issue?
Also, we recommend to update the resinOS from 2.12.0 to 2.12.3


Ok - thanx for the help
I will try this afternoon

Thanx for the help - the problem had nothing to do with the resin image but with the other bluetooth device.

sorry about the noise