Update homeassistant-core-install.sh

This commit is contained in:
CanbiZ 2025-05-09 10:16:06 +02:00
parent 0c40bf9a52
commit a03c89d462

View File

@ -50,20 +50,29 @@ setup_uv
msg_info "Setup Python3" msg_info "Setup Python3"
$STD apt-get install -y \ $STD apt-get install -y \
python3.13 \ python3.13 \
python3-pip \
python3.13-dev \ python3.13-dev \
python3.13-venv python3.13-venv
msg_ok "Setup Python3" msg_ok "Setup Python3"
msg_info "Preparing Python 3.13 for uv"
uv python install 3.13
UV_PYTHON=$(uv python list | awk '/3\.13\.[0-9]+.*\/root\/.local/ {print $2; exit}')
if [[ -z "$UV_PYTHON" ]]; then
msg_error "No local Python 3.13 found via uv"
exit 1
fi
msg_ok "Prepared Python 3.13"
msg_info "Setting up Home Assistant-Core environment" msg_info "Setting up Home Assistant-Core environment"
rm -rf /srv/homeassistant
mkdir -p /srv/homeassistant mkdir -p /srv/homeassistant
cd /srv/homeassistant cd /srv/homeassistant
uv venv . uv venv .venv --python "$UV_PYTHON"
source bin/activate source .venv/bin/activate
msg_ok "Created virtual environment" msg_ok "Created virtual environment"
msg_info "Installing Home Assistant-Core" msg_info "Installing Home Assistant-Core"
$STD uv pip install --all-extras homeassistant mysqlclient psycopg2-binary isal webrtcvad wheel $STD uv pip install homeassistant mysqlclient psycopg2-binary isal webrtcvad wheel
mkdir -p /root/.homeassistant mkdir -p /root/.homeassistant
msg_ok "Installed Home Assistant-Core" msg_ok "Installed Home Assistant-Core"
@ -72,16 +81,19 @@ cat <<EOF >/etc/systemd/system/homeassistant.service
[Unit] [Unit]
Description=Home Assistant Description=Home Assistant
After=network-online.target After=network-online.target
[Service] [Service]
Type=simple Type=simple
WorkingDirectory=/root/.homeassistant WorkingDirectory=/root/.homeassistant
Environment="PATH=/srv/homeassistant/bin:/usr/local/bin:/usr/bin:/usr/local/bin/uv" Environment="PATH=/srv/homeassistant/.venv/bin:/usr/local/bin:/usr/bin"
ExecStart=/srv/homeassistant/bin/python3 -m homeassistant --config /root/.homeassistant ExecStart=/srv/homeassistant/.venv/bin/python3 -m homeassistant --config /root/.homeassistant
Restart=always Restart=always
RestartForceExitStatus=100 RestartForceExitStatus=100
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl enable -q --now homeassistant systemctl enable -q --now homeassistant
msg_ok "Created Service" msg_ok "Created Service"