homassistant #56

Merged
kunsi merged 6 commits from homassistant into main 2022-12-24 17:32:39 +00:00
3 changed files with 102 additions and 0 deletions
Showing only changes of commit c407a4520a - Show all commits

View file

@ -0,0 +1,13 @@
[Unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=simple
User=homeassistant
WorkingDirectory=/var/opt/homeassistant
ExecStart=/opt/homeassistant/bin/hass -c "/var/opt/homeassistant"
RestartForceExitStatus=100
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,66 @@
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',
},
},
}

View file

@ -0,0 +1,23 @@
defaults = {
'apt': {
'packages': {
'bluez': {},
'libffi-dev': {},
'libssl-dev': {},
'libjpeg-dev': {},
'zlib1g-dev': {},
'autoconf': {},
'build-essential': {},
'libopenjp2-7': {},
'libtiff5': {},
'libturbojpeg0-dev': {},
'tzdata': {},
},
},
'backups': {
'paths': {
'/opt/homeassistant',
'/var/opt/homeassistant',
},
},
}