mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-24 09:36:31 +00:00
Minor change v2
This commit is contained in:
parent
ccd9952ba8
commit
e454b8ded9
@ -13,16 +13,41 @@ class DockerBase(object):
|
||||
self.dock = dock
|
||||
self.image = image
|
||||
self.tag = tag
|
||||
self.container = None
|
||||
|
||||
async def install(tag='latest'):
|
||||
"""Pull docker image."""
|
||||
def install(self, tag='latest'):
|
||||
"""Pull docker image.
|
||||
|
||||
Return a Future.
|
||||
"""
|
||||
return self.loop.run_in_executor(None, self._install, tag)
|
||||
|
||||
def _install(self, tag='latest'):
|
||||
"""Pull docker image.
|
||||
|
||||
Need run inside executor.
|
||||
"""
|
||||
try:
|
||||
self.dock.images.pull(self.image, tag=tag)
|
||||
|
||||
if tag != "latest":
|
||||
image = self.dock.images.get("{}:{}".format(self.image, tag))
|
||||
image.tag(self.image, tag='latest')
|
||||
except docker.errors.APIError as err:
|
||||
_LOGGER.error("Can't pull %s:%s", self.image, tag)
|
||||
return False
|
||||
return True
|
||||
|
||||
async def run():
|
||||
"""Run docker image."""
|
||||
def run():
|
||||
"""Run docker image.
|
||||
|
||||
Return a Future.
|
||||
"""
|
||||
return self.loop.run_in_executor(None, self._run, tag)
|
||||
|
||||
def _run():
|
||||
"""Run docker image.
|
||||
|
||||
Need run inside executor.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
@ -9,12 +9,25 @@ import . from DockerBase
|
||||
class DockerHomeAssistant(DockerBase):
|
||||
"""Docker hassio wrapper for HomeAssistant."""
|
||||
|
||||
async def run():
|
||||
"""Run docker image."""
|
||||
def _run():
|
||||
"""Run docker image.
|
||||
|
||||
Need run inside executor.
|
||||
"""
|
||||
try:
|
||||
self.docker.images.pull(self.image, tag=tag)
|
||||
self.container = self.dock.containers.run(
|
||||
self.image,
|
||||
remove=True,
|
||||
network_mode='host',
|
||||
restart_policy={
|
||||
"Name": "always",
|
||||
"MaximumRetryCount": 10,
|
||||
},
|
||||
volumes={
|
||||
'/data': {'bind': '/data', 'mode': 'rw'}
|
||||
})
|
||||
except docker.errors.APIError as err:
|
||||
_LOGGER.error("Can't pull %s:%s", self.image, tag)
|
||||
_LOGGER.error("Can't run %s", self.image)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -20,8 +20,8 @@ do_install_append() {
|
||||
install -m 0755 ${WORKDIR}/sync-authorized-keys.sh ${D}${bindir}
|
||||
|
||||
if [ "${RESIN_CONNECTABLE_ENABLE_SERVICES}" = "1" ]; then
|
||||
rm -r ${D}${localstatedir}/lib/dropbear/
|
||||
rm ${D}/home/root/.ssh/authorized_keys
|
||||
rm -fr ${D}${localstatedir}/lib/dropbear/
|
||||
rm -f ${D}/home/root/.ssh/authorized_keys
|
||||
fi
|
||||
|
||||
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
|
||||
|
6
meta-hassio/recipes-core/images/resin-image.bbappend.txt
Normal file
6
meta-hassio/recipes-core/images/resin-image.bbappend.txt
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
PREFERRED_PROVIDER_docker-disk = "docker-resin-supervisor-disk"
|
||||
RESIN_CONNECTABLE_SERVICES_remove = "openvpn"
|
||||
RESIN_CONNECTABLE_SERVICES_remove = "docker-resin-supervisor-disk"
|
||||
DISTRO_FEATURES_remove = "development-image"
|
||||
DISTRO_FEATURES_remove = "debug-image"
|
Loading…
x
Reference in New Issue
Block a user