Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion supervisor/addons/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
_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"
Expand Down
5 changes: 5 additions & 0 deletions supervisor/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
11 changes: 11 additions & 0 deletions supervisor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
APPARMOR_DATA = PurePath("apparmor")
DNS_DATA = PurePath("dns")
AUDIO_DATA = PurePath("audio")
MEDIA_DATA = PurePath("media")

DEFAULT_BOOT_TIME = datetime.utcfromtimestamp(0).isoformat()

Expand Down Expand Up @@ -258,6 +259,16 @@ def path_dns(self) -> Path:
"""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."""
Expand Down
2 changes: 2 additions & 0 deletions supervisor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
MAP_ADDONS = "addons"
MAP_BACKUP = "backup"
MAP_SHARE = "share"
MAP_MEDIA = "media"

ARCH_ARMHF = "armhf"
ARCH_ARMV7 = "armv7"
Expand All @@ -305,6 +306,7 @@
FOLDER_SHARE = "share"
FOLDER_ADDONS = "addons/local"
FOLDER_SSL = "ssl"
FOLDER_MEDIA = "media"

SNAPSHOT_FULL = "full"
SNAPSHOT_PARTIAL = "partial"
Expand Down
11 changes: 11 additions & 0 deletions supervisor/docker/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
MAP_ADDONS,
MAP_BACKUP,
MAP_CONFIG,
MAP_MEDIA,
MAP_SHARE,
MAP_SSL,
SECURITY_DISABLE,
Expand Down Expand Up @@ -269,6 +270,16 @@ def volumes(self) -> Dict[str, Dict[str, str]]:
}
)

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
Expand Down
4 changes: 4 additions & 0 deletions supervisor/docker/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def volumes(self) -> Dict[str, Dict[str, str]]:
"bind": "/share",
"mode": "rw",
},
str(self.sys_config.path_extern_media): {
"bind": "/media",
"mode": "rw",
},
}
)

Expand Down
9 changes: 8 additions & 1 deletion supervisor/snapshots/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@
CRYPTO_AES128,
FOLDER_ADDONS,
FOLDER_HOMEASSISTANT,
FOLDER_MEDIA,
FOLDER_SHARE,
FOLDER_SSL,
SNAPSHOT_FULL,
SNAPSHOT_PARTIAL,
)
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):
Expand Down