mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-16 06:20:10 +00:00
* Add CoreDNS / DNS configuration * Support get version * add version * add coresys * Add more logic * move forwareder into dns * Setup docker inside * add docker to env * Add more function * more interface * Update hosts template * Add DNS folder * Fix issues * Add more logic * Add handling for hosts * Fix setting * fix lint * Fix some issues * Fix issue * Run with no cache * Fix issue on validate * Fix bug * Allow to jump into dev mode * Fix permission * Fix issue * Add dns search * Add watchdog * Fix set issues * add API description * Add API endpoint * Add CLI support * Fix logs + add hostname * Add/remove DNS entry * Fix attribute * Fix style * Better shutdown * Remove ha from network mapping * Add more options * Fix env shutdown * Add support for new repair function * Start coreDNS faster after restart * remove options * Fix ha fix
57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
"""HassOS Cli docker object."""
|
|
from contextlib import suppress
|
|
import logging
|
|
|
|
from ..const import ENV_TIME
|
|
from ..coresys import CoreSysAttributes
|
|
from ..exceptions import DockerAPIError
|
|
from .interface import DockerInterface
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
DNS_DOCKER_NAME: str = "hassio_dns"
|
|
|
|
|
|
class DockerDNS(DockerInterface, CoreSysAttributes):
|
|
"""Docker Hass.io wrapper for Hass.io DNS."""
|
|
|
|
@property
|
|
def image(self) -> str:
|
|
"""Return name of Hass.io DNS image."""
|
|
return f"homeassistant/{self.sys_arch.supervisor}-hassio-dns"
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
"""Return name of Docker container."""
|
|
return DNS_DOCKER_NAME
|
|
|
|
def _run(self) -> None:
|
|
"""Run Docker image.
|
|
|
|
Need run inside executor.
|
|
"""
|
|
if self._is_running():
|
|
return
|
|
|
|
# Cleanup
|
|
with suppress(DockerAPIError):
|
|
self._stop()
|
|
|
|
# Create & Run container
|
|
docker_container = self.sys_docker.run(
|
|
self.image,
|
|
version=self.sys_dns.version,
|
|
ipv4=self.sys_docker.network.dns,
|
|
name=self.name,
|
|
hostname=self.name.replace("_", "-"),
|
|
detach=True,
|
|
init=True,
|
|
environment={ENV_TIME: self.sys_timezone},
|
|
volumes={
|
|
str(self.sys_config.path_extern_dns): {"bind": "/config", "mode": "ro"}
|
|
},
|
|
)
|
|
|
|
self._meta = docker_container.attrs
|
|
_LOGGER.info("Start DNS %s with version %s", self.image, self.version)
|