Allow Core access to dbus for bluetooth (#1883)

This commit is contained in:
Pascal Vizeli 2020-08-10 15:18:32 +02:00 committed by GitHub
parent 7deed55c2d
commit 19ca485c28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 6 deletions

View File

@ -19,6 +19,7 @@ from .const import (
ENV_SUPERVISOR_MACHINE,
ENV_SUPERVISOR_NAME,
ENV_SUPERVISOR_SHARE,
MACHINE_ID,
SOCKET_DOCKER,
SUPERVISOR_VERSION,
CoreStates,
@ -48,9 +49,6 @@ from .utils.dt import fetch_timezone
_LOGGER: logging.Logger = logging.getLogger(__name__)
MACHINE_ID = Path("/etc/machine-id")
async def initialize_coresys() -> CoreSys:
"""Initialize supervisor coresys/objects."""
coresys = CoreSys()

View File

@ -30,6 +30,7 @@ FILE_HASSIO_AUDIO = Path(SUPERVISOR_DATA, "audio.json")
FILE_HASSIO_CLI = Path(SUPERVISOR_DATA, "cli.json")
FILE_HASSIO_MULTICAST = Path(SUPERVISOR_DATA, "multicast.json")
MACHINE_ID = Path("/etc/machine-id")
SOCKET_DOCKER = Path("/run/docker.sock")
DOCKER_NETWORK = "hassio"

View File

@ -4,7 +4,7 @@ import logging
from pathlib import Path
from typing import Dict
from ..const import ENV_TIME
from ..const import ENV_TIME, MACHINE_ID
from ..coresys import CoreSysAttributes
from ..exceptions import DockerAPIError
from .interface import DockerInterface
@ -35,6 +35,10 @@ class DockerAudio(DockerInterface, CoreSysAttributes):
"/run/dbus": {"bind": "/run/dbus", "mode": "ro"},
}
# Machine ID
if MACHINE_ID.exists():
volumes.update({str(MACHINE_ID): {"bind": str(MACHINE_ID), "mode": "ro"}})
# SND support
if Path("/dev/snd").exists():
volumes.update({"/dev/snd": {"bind": "/dev/snd", "mode": "rw"}})

View File

@ -6,7 +6,7 @@ from typing import Awaitable, Dict, Optional
import docker
from ..const import ENV_TIME, ENV_TOKEN, ENV_TOKEN_OLD, LABEL_MACHINE
from ..const import ENV_TIME, ENV_TOKEN, ENV_TOKEN_OLD, LABEL_MACHINE, MACHINE_ID
from ..exceptions import DockerAPIError
from .interface import CommandReturn, DockerInterface
@ -48,7 +48,7 @@ class DockerHomeAssistant(DockerInterface):
@property
def volumes(self) -> Dict[str, Dict[str, str]]:
"""Return Volumes for the mount."""
volumes = {}
volumes = {"/run/dbus": {"bind": "/run/dbus", "mode": "ro"}}
# Add folders
volumes.update(
@ -65,6 +65,10 @@ class DockerHomeAssistant(DockerInterface):
}
)
# Machine ID
if MACHINE_ID.exists():
volumes.update({str(MACHINE_ID): {"bind": str(MACHINE_ID), "mode": "ro"}})
# Configuration Audio
volumes.update(
{