diff --git a/supervisor/bootstrap.py b/supervisor/bootstrap.py index 2d7b3a70e..e87175c3b 100644 --- a/supervisor/bootstrap.py +++ b/supervisor/bootstrap.py @@ -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() diff --git a/supervisor/const.py b/supervisor/const.py index fe74f6133..8312d2a42 100644 --- a/supervisor/const.py +++ b/supervisor/const.py @@ -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" diff --git a/supervisor/docker/audio.py b/supervisor/docker/audio.py index 01c037c5a..c5fd1749d 100644 --- a/supervisor/docker/audio.py +++ b/supervisor/docker/audio.py @@ -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"}}) diff --git a/supervisor/docker/homeassistant.py b/supervisor/docker/homeassistant.py index dd94b5963..27b4c1b99 100644 --- a/supervisor/docker/homeassistant.py +++ b/supervisor/docker/homeassistant.py @@ -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( {