summarylogtreecommitdiffstats
path: root/hass-update.service
blob: 6392f79f270586aeb437b742fd42e5f105b1466a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
[Unit]
Description=Home assistant update
After=network.target

[Service]
User=hass
Group=hass
LogsDirectory=hass
StateDirectory=hass
WorkingDirectory=~

EnvironmentFile=-/etc/hass.env

Type=oneshot
# upgrade home assistant and all its necessary libs
ExecStart=pip install --no-warn-script-location --user --upgrade homeassistant

# temp workaround for https://github.com/home-assistant/core/issues/74405
ExecStart = sh -c "find $(python -c 'import site; print(site.getusersitepackages())') -wholename '*/homeassistant/util/package.py' -exec sed -i '/--prefix=/d' {} \; "

# delete old python version libraries in the venv
ExecStart=sh -c '\
find \
$(python -c "import os.path as path; import site; print(path.dirname(path.dirname(site.getusersitepackages())))") -mindepth 1 -type d \
-path $(python -c "import os.path as path; import site; print(path.basename(path.dirname(path.relpath(site.getusersitepackages(),site.getuserbase()))))") -prune \
-print0 \
| xargs --no-run-if-empty -0 rm --verbose --recursive'

LockPersonality=true
RestrictRealtime=true
RestrictSUIDSGID=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
PrivateMounts=true
PrivateTmp=true
ProtectSystem=full
PrivateDevices=true

[Install]
WantedBy=multi-user.target