diff --git a/supervisor/__main__.py b/supervisor/__main__.py index 806292940..2db75bd8d 100644 --- a/supervisor/__main__.py +++ b/supervisor/__main__.py @@ -30,8 +30,7 @@ if __name__ == "__main__": loop = initialize_event_loop() # Check if all information are available to setup Supervisor - if not bootstrap.check_environment(): - sys.exit(1) + bootstrap.check_environment() # init executor pool executor = ThreadPoolExecutor(thread_name_prefix="SyncWorker") diff --git a/supervisor/audio.py b/supervisor/audio.py index a9dc9ed80..e7d84236d 100644 --- a/supervisor/audio.py +++ b/supervisor/audio.py @@ -188,13 +188,6 @@ class Audio(JsonConfig, CoreSysAttributes): """ return self.instance.is_running() - def is_fails(self) -> Awaitable[bool]: - """Return True if a Docker container is fails state. - - Return a coroutine. - """ - return self.instance.is_fails() - async def repair(self) -> None: """Repair CoreDNS plugin.""" if await self.instance.exists(): diff --git a/supervisor/bootstrap.py b/supervisor/bootstrap.py index b70b81f4f..1c467a246 100644 --- a/supervisor/bootstrap.py +++ b/supervisor/bootstrap.py @@ -197,7 +197,7 @@ def initialize_logging(): ) -def check_environment(): +def check_environment() -> None: """Check if all environment are exists.""" # check environment variables for key in (ENV_SHARE, ENV_NAME, ENV_REPO): @@ -205,24 +205,18 @@ def check_environment(): os.environ[key] except KeyError: _LOGGER.fatal("Can't find %s in env!", key) - return False # check docker socket if not SOCKET_DOCKER.is_socket(): _LOGGER.fatal("Can't find Docker socket!") - return False # check socat exec if not shutil.which("socat"): _LOGGER.fatal("Can't find socat!") - return False # check socat exec if not shutil.which("gdbus"): _LOGGER.fatal("Can't find gdbus!") - return False - - return True def reg_signal(loop): diff --git a/supervisor/const.py b/supervisor/const.py index 710b53bbe..3f36e54ff 100644 --- a/supervisor/const.py +++ b/supervisor/const.py @@ -3,7 +3,7 @@ from enum import Enum from ipaddress import ip_network from pathlib import Path -SUPERVISOR_VERSION = "207" +SUPERVISOR_VERSION = "208" URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons" @@ -28,7 +28,7 @@ FILE_HASSIO_INGRESS = Path(SUPERVISOR_DATA, "ingress.json") FILE_HASSIO_DNS = Path(SUPERVISOR_DATA, "dns.json") FILE_HASSIO_AUDIO = Path(SUPERVISOR_DATA, "audio.json") -SOCKET_DOCKER = Path("/var/run/docker.sock") +SOCKET_DOCKER = Path("/run/docker.sock") DOCKER_NETWORK = "hassio" DOCKER_NETWORK_MASK = ip_network("172.30.32.0/23") diff --git a/supervisor/hwmon.py b/supervisor/hwmon.py index 8e911cff5..6ce1d90bb 100644 --- a/supervisor/hwmon.py +++ b/supervisor/hwmon.py @@ -19,20 +19,25 @@ class HwMonitor(CoreSysAttributes): """Initialize Hardware Monitor object.""" self.coresys: CoreSys = coresys self.context = pyudev.Context() - self.monitor = pyudev.Monitor.from_netlink(self.context) + self.monitor: Optional[pyudev.Monitor] = None self.observer: Optional[pyudev.MonitorObserver] = None async def load(self) -> None: """Start hardware monitor.""" - self.observer = pyudev.MonitorObserver(self.monitor, self._udev_events) - self.observer.start() - - _LOGGER.info("Start Supervisor hardware monitor") + try: + self.monitor = pyudev.Monitor.from_netlink(self.context) + self.observer = pyudev.MonitorObserver(self.monitor, self._udev_events) + except OSError: + _LOGGER.fatal("Not privileged to run udev. Update your installation!") + else: + self.observer.start() + _LOGGER.info("Started Supervisor hardware monitor") async def unload(self) -> None: """Shutdown sessions.""" if self.observer is None: return + self.observer.stop() _LOGGER.info("Stop Supervisor hardware monitor") diff --git a/supervisor/tasks.py b/supervisor/tasks.py index e39d4afe9..bab7a8211 100644 --- a/supervisor/tasks.py +++ b/supervisor/tasks.py @@ -228,7 +228,7 @@ class Tasks(CoreSysAttributes): async def _watchdog_dns_docker(self): """Check running state of Docker and start if they is close.""" # if CoreDNS is active - if await self.sys_dns.is_running(): + if await self.sys_dns.is_running() or self.sys_dns.in_progress: return _LOGGER.warning("Watchdog found a problem with CoreDNS plugin!") @@ -244,7 +244,7 @@ class Tasks(CoreSysAttributes): async def _watchdog_audio_docker(self): """Check running state of Docker and start if they is close.""" # if PulseAudio plugin is active - if await self.sys_audio.is_running(): + if await self.sys_audio.is_running() or self.sys_audio.in_progress: return _LOGGER.warning("Watchdog found a problem with PulseAudio plugin!")