bundlewrap/bundles/homeassistant/items.py
2022-12-22 17:37:13 +01:00

66 lines
1.7 KiB
Python

users = {
'homeassistant': {
'home': '/var/opt/homeassistant',
},
}
directories = {
'/opt/homeassistant': {},
'/var/opt/homeassistant': {
'owner': 'homeassistant',
},
}
files = {
'/etc/systemd/system/homeassistant.service': {
'triggers': {
'action:systemd-reload',
'svc_systemd:homeassistant:restart',
},
},
}
actions = {
'homeassistant_create_virtualenv': {
'command': '/usr/bin/python3 -m virtualenv -p python3 /opt/homeassistant/venv',
'unless': 'test -d /opt/homeassistant/venv/',
'needed_by': {
'action:homeassistant_install',
},
},
'homeassistant_install': {
'triggered': True,
'command': ' && '.join([
'cd /opt/homeassistant/src',
f"/opt/homeassistant/venv/bin/pip install --upgrade homeassistant=={node.metadata.get('homeassistant/version')}",
]) ,
'needs': {
'pkg_apt:bluez',
'pkg_apt:libffi-dev',
'pkg_apt:libssl-dev',
'pkg_apt:libjpeg-dev',
'pkg_apt:zlib1g-dev',
'pkg_apt:autoconf',
'pkg_apt:build-essential',
'pkg_apt:libopenjp2-7',
'pkg_apt:libtiff5',
'pkg_apt:libturbojpeg0-dev',
'pkg_apt:tzdata',
},
'triggers': {
'svc_systemd:homeassistant:restart',
},
'unless': {
"[[ $(/opt/homeassistant/venv/bin/pip freeze | grep homeassistant=={node.metadata.get('homeassistant/version')}) ]]",
},
},
}
svc_systemd = {
'homeassistant': {
'needs': {
'action:homeassistant_install',
'file:/etc/systemd/system/homeassistant.service',
},
},
}