mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 20:26:29 +00:00
Add support for media folder (#2034)
This commit is contained in:
parent
b60d57c3a0
commit
0675f66ee6
@ -105,7 +105,7 @@ from ..validate import (
|
||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
RE_VOLUME = re.compile(r"^(config|ssl|addons|backup|share)(?::(rw|ro))?$")
|
||||
RE_VOLUME = re.compile(r"^(config|ssl|addons|backup|share|media)(?::(rw|ro))?$")
|
||||
RE_SERVICE = re.compile(r"^(?P<service>mqtt|mysql):(?P<rights>provide|want|need)$")
|
||||
|
||||
V_STR = "str"
|
||||
|
@ -164,6 +164,11 @@ def initialize_system_data(coresys: CoreSys) -> None:
|
||||
_LOGGER.info("Create Supervisor audio folder %s", config.path_audio)
|
||||
config.path_audio.mkdir()
|
||||
|
||||
# Media folder
|
||||
if not config.path_media.is_dir():
|
||||
_LOGGER.info("Create Supervisor media folder %s", config.path_media)
|
||||
config.path_media.mkdir()
|
||||
|
||||
# Update log level
|
||||
coresys.config.modify_log_level()
|
||||
|
||||
|
@ -41,6 +41,7 @@ TMP_DATA = PurePath("tmp")
|
||||
APPARMOR_DATA = PurePath("apparmor")
|
||||
DNS_DATA = PurePath("dns")
|
||||
AUDIO_DATA = PurePath("audio")
|
||||
MEDIA_DATA = PurePath("media")
|
||||
|
||||
DEFAULT_BOOT_TIME = datetime.utcfromtimestamp(0).isoformat()
|
||||
|
||||
@ -258,6 +259,16 @@ class CoreConfig(JsonConfig):
|
||||
"""Return dns path inside supervisor."""
|
||||
return Path(SUPERVISOR_DATA, DNS_DATA)
|
||||
|
||||
@property
|
||||
def path_media(self) -> Path:
|
||||
"""Return root media data folder."""
|
||||
return Path(SUPERVISOR_DATA, MEDIA_DATA)
|
||||
|
||||
@property
|
||||
def path_extern_media(self) -> PurePath:
|
||||
"""Return root media data folder external for Docker."""
|
||||
return PurePath(self.path_extern_supervisor, MEDIA_DATA)
|
||||
|
||||
@property
|
||||
def addons_repositories(self) -> List[str]:
|
||||
"""Return list of custom Add-on repositories."""
|
||||
|
@ -289,6 +289,7 @@ MAP_SSL = "ssl"
|
||||
MAP_ADDONS = "addons"
|
||||
MAP_BACKUP = "backup"
|
||||
MAP_SHARE = "share"
|
||||
MAP_MEDIA = "media"
|
||||
|
||||
ARCH_ARMHF = "armhf"
|
||||
ARCH_ARMV7 = "armv7"
|
||||
@ -305,6 +306,7 @@ FOLDER_HOMEASSISTANT = "homeassistant"
|
||||
FOLDER_SHARE = "share"
|
||||
FOLDER_ADDONS = "addons/local"
|
||||
FOLDER_SSL = "ssl"
|
||||
FOLDER_MEDIA = "media"
|
||||
|
||||
SNAPSHOT_FULL = "full"
|
||||
SNAPSHOT_PARTIAL = "partial"
|
||||
|
@ -19,6 +19,7 @@ from ..const import (
|
||||
MAP_ADDONS,
|
||||
MAP_BACKUP,
|
||||
MAP_CONFIG,
|
||||
MAP_MEDIA,
|
||||
MAP_SHARE,
|
||||
MAP_SSL,
|
||||
SECURITY_DISABLE,
|
||||
@ -269,6 +270,16 @@ class DockerAddon(DockerInterface):
|
||||
}
|
||||
)
|
||||
|
||||
if MAP_MEDIA in addon_mapping:
|
||||
volumes.update(
|
||||
{
|
||||
str(self.sys_config.path_extern_media): {
|
||||
"bind": "/media",
|
||||
"mode": addon_mapping[MAP_MEDIA],
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
# Init other hardware mappings
|
||||
|
||||
# GPIO support
|
||||
|
@ -62,6 +62,10 @@ class DockerHomeAssistant(DockerInterface):
|
||||
"bind": "/share",
|
||||
"mode": "rw",
|
||||
},
|
||||
str(self.sys_config.path_extern_media): {
|
||||
"bind": "/media",
|
||||
"mode": "rw",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -26,6 +26,7 @@ from ..const import (
|
||||
CRYPTO_AES128,
|
||||
FOLDER_ADDONS,
|
||||
FOLDER_HOMEASSISTANT,
|
||||
FOLDER_MEDIA,
|
||||
FOLDER_SHARE,
|
||||
FOLDER_SSL,
|
||||
SNAPSHOT_FULL,
|
||||
@ -33,7 +34,13 @@ from ..const import (
|
||||
)
|
||||
from ..validate import docker_image, network_port, repositories, version_tag
|
||||
|
||||
ALL_FOLDERS = [FOLDER_HOMEASSISTANT, FOLDER_SHARE, FOLDER_ADDONS, FOLDER_SSL]
|
||||
ALL_FOLDERS = [
|
||||
FOLDER_HOMEASSISTANT,
|
||||
FOLDER_SHARE,
|
||||
FOLDER_ADDONS,
|
||||
FOLDER_SSL,
|
||||
FOLDER_MEDIA,
|
||||
]
|
||||
|
||||
|
||||
def unique_addons(addons_list):
|
||||
|
Loading…
x
Reference in New Issue
Block a user