burmilla / os

Tiny Linux distro that runs the entire OS as Docker containers
https://burmillaos.org
Apache License 2.0
210 stars 13 forks source link

Bluetooth support #172

Closed anselstetter closed 6 months ago

anselstetter commented 7 months ago

Hi @ all,

I have a kinda niche problem, and I don't know if this is possible.

I'm running v2.0.0-beta4 on a Raspberry Pi 4, with a bunch of services.

My latest addition is home assistant, which is working great so far. The only thing which is not working is Bluetooth, since it is required to have BlueZ installed.

Is it possible to have this integrated somehow as a system service?

I've searched through the documentation and repositories, but I did not find any clues to solve this problem.

olljanat commented 7 months ago

Because our console is actually based on Debian nowadays it should be possible to install it with sudo apt-get install bluez

Only extra hack which needed is that you need use rc.local to get it started automatically: https://burmillaos.org/docs/configuration/advanced/write-files/

However, as warning when it comes Raspberry Pi 4, it is a bit unclear if that will receive updates because lack of maintainers on this project.

anselstetter commented 7 months ago

Thanks for the quick answer and warning.

I'll try it out.

anselstetter commented 7 months ago

A quick update and maybe a little information for future readers, who are interested, or have the same problem.

After trying to install BlueZ, I've run into some issues.

(For context: I'm not super familiar with Debian)

I've tried to update the repository, which failed, because some GPG keys were unknown.

I've solved this one, but the installation of BlueZ failed half way, with the option to fix the installation with apt --fix-broken install, which I did.

This one also failed, because libcrypt.so was not found. (I'm paraphrasing here, because I didn't write down the exact library version.)

So I've downloaded the lib, moved it into the corresponding directory and this was the end of my journey.

I've tried to rerun the fix-broken-install command and all I've got was: sudo: account validation failure, is your account locked?

I'm using Linux since 2000-ish and this one is a first. :slightly_smiling_face:

Instead of wasting any more time with this, I've decided to start fresh.

After a new installation, with my backup restored, I've come up with a duct tape solution, which works surprisingly well.

So let's embrace Docker and not fight it.

This is my solution:

bluetooth.yml

bluetooth:
  image: bluetooth:latest
  container_name: bluetooth
  build: ./bluetooth
  restart: always
  net: host
  privileged: true
  volumes:
    - /run/dbus:/run/dbus

./bluetooth/Dockerfile

FROM alpine:latest

RUN apk add --no-cache bluez dbus openrc

RUN rc-update add dbus default \
 && rc-update add bluetooth default \
 && mkdir /run/openrc \
 && touch /run/openrc/softlevel

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]

./bluetooth/entrypoint.sh

#!/bin/sh

rc-status -a
rc-service dbus start
rc-service bluetooth start

sleep infinity

And for good measure:

home-assistant.yml

home_assistant:
  image: ghcr.io/home-assistant/home-assistant:stable
  container_name: home_assistant
  depends_on:
    - bluetooth
    - mosquitto
  restart: always
  net: host
  cap_add:
    - NET_ADMIN
  volumes:
    - /mnt/data/docker/home-assistant:/config
    - /etc/localtime:/etc/localtime:ro
    - /run/dbus:/run/dbus:ro

caddy.yml

caddy:
  image: caddy
  container_name: caddy
  restart: always
  net: web
  ports:
    - "80:80"
    - "443:443"
  extra_hosts:
    - "host.docker.internal:host-gateway"
  volumes:
    - /mnt/data/docker/caddy:/.local/share/caddy
    - /mnt/data/docker/caddy/Caddyfile:/etc/caddy/Caddyfile
    - /mnt/data/static:/static
olljanat commented 7 months ago

Those issues are most likely result of beta4 missing this https://github.com/burmilla/os/pull/111

You can do same by changing all stable texts to bullseye in file /etc/apt/sources.

However, it might be that you need reset console first like it is described on https://github.com/burmilla/os/releases/tag/v2.0.0-rc2