NebraLtd / helium-miner-software

Software for Nebra (and third party) Helium Miners
https://nebra.io/hnt
MIT License
94 stars 48 forks source link

balena dbus config file / hostapps #105

Closed shawaj closed 2 years ago

shawaj commented 3 years ago

In order to better support multiple hardwares, we ideally need balena hostapps to be available to us.

Otherwise, for every hardware variant we will need a custom machine type on balena to pull in the dbus config file

<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <policy user="root">
    <allow own="com.helium.Miner"/>
    <allow send_interface="com.helium.Miner"/>
  </policy>
  <policy context="default">
     <allow send_destination="com.helium.Miner"/>
  </policy>
</busconfig>

Ref: https://github.com/helium/miner/blob/master/config/com.helium.Miner.conf

This needs to be placed on the host os at /etc/dbus-1/system.d as has been done here for the nebra-hnt device type on balena https://github.com/balena-os/balena-raspberrypi/blob/master/layers/meta-balena-raspberrypi/recipes-core/dbus/dbus_%25.bbappend

Currently, we have to manually add this for different devices types by removing read only from filesystem and adding the file in https://forums.balena.io/t/i-want-to-edit-host-os-read-only-files/21266

vpetersson commented 3 years ago

Just FYI @marvinmarnold

shawaj commented 3 years ago

Have created a solution with the help of the dbus balenaBlock: https://github.com/balenablocks/dbus https://forums.balena.io/t/dbus-balena-block-configuration/348962/16 https://hub.docker.com/r/balenablocks/dbus

Once these commits are merged:

We can then update docker-compose.yml to the following (changing out for updated container tags):

version: '2'

services:

  gateway-config:
    image: nebraltd/hm-config:c50addcbcbc33f094168497db1b2653490211518
    depends_on:
      - dbus-session
    environment:
      - FIRMWARE_VERSION=2021.09.27.0
      - DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
      - DBUS_SESSION_BUS_ADDRESS=unix:path=/session/dbus/session_bus_socket
    privileged: true
    network_mode: "host"
    cap_add:
      - NET_ADMIN
    volumes:
      - miner-storage:/var/data
      - dbus:/session/dbus
    labels:
      io.balena.features.sysfs: '1'
      io.balena.features.kernel-modules: '1'
      io.balena.features.dbus: '1'
    stop_signal: SIGINT

  packet-forwarder:
    image: nebraltd/hm-pktfwd:477eeda57ca9ebcb3909eebb8e869776a95b1668
    privileged: true
    volumes:
      - pktfwdr:/var/pktfwd

  helium-miner:
    image: nebraltd/hm-miner:70dbc27b98c233e969001f8e3bb91371a3ef7bdb
    depends_on:
      - dbus-session
    expose:
      - "1680"
      - "4467"
    ports:
      - "44158:44158/tcp"
    volumes:
      - miner-storage:/var/data
      - miner-log:/var/log/miner
      - pktfwdr:/var/pktfwd
      - dbus:/session/dbus
    cap_add:
      - SYS_RAWIO
    devices:
      - "/dev/i2c-1:/dev/i2c-1"
    environment:
      - DBUS_SYSTEM_BUS_ADDRESS=unix:path=/session/dbus/session_bus_socket
      - RELEASE_BUMPER=foobar

  diagnostics:
    image: nebraltd/hm-diag:b1b9eb24903f9b2e101f85894599f2a849f36c6a
    depends_on:
      - dbus-session
    environment:
      - FIRMWARE_VERSION=2021.09.27.0
      - DBUS_SESSION_BUS_ADDRESS=unix:path=/session/dbus/session_bus_socket
    volumes:
      - pktfwdr:/var/pktfwd
      - miner-storage:/var/data
      - dbus:/session/dbus
    ports:
      - "80:5000"
    cap_add:
      - SYS_RAWIO
    devices:
      - "/dev/i2c-1:/dev/i2c-1"
    labels:
      io.balena.features.sysfs: '1'

  gwmfr:
    image: nebraltd/hm-gwmfr:f84834b70e34520e63d4a2dda521a198feb66b71
    cap_add:
      - SYS_RAWIO
    devices:
      - "/dev/i2c-1:/dev/i2c-1"
    restart: on-failure

  upnp:
    image: nebraltd/hm-upnp:4e419f5bb5d59b31fcd1f81e0c94f7e94cd9ebee
    network_mode: "host"
    restart: on-failure
    volumes:
      - pktfwdr:/var/pktfwd

  dbus-session:
    image: balenablocks/dbus:rpi-0.0.2
    restart: always
    volumes:
      - dbus:/session/dbus
    environment:
      - DBUS_ADDRESS=unix:path=/session/dbus/session_bus_socket

volumes:
  miner-storage:
  miner-log:
  pktfwdr:
  dbus:
shawaj commented 3 years ago

Have tested on the following device types:

Also planning to test shortly on:

And probably some others...

shawaj commented 3 years ago

All tested on Nebra

@vpetersson @marvinmarnold can probably promote this to testnet for further testing at some point if we want to

(the containers are all ready for it already, just need to update the docker-compose.yml)

shawaj commented 3 years ago

Deployed to testnet ^^

shawaj commented 2 years ago

Closed by #163