1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-05-10 02:43:08 +00:00

Update homeassistant-core-install.sh

This commit is contained in:
CanbiZ 2025-05-09 21:58:08 +02:00 committed by GitHub
parent 2a14d51b69
commit 5f3f5d9479
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -46,29 +46,33 @@ $STD apt-get install -y \
pkg-config pkg-config
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
setup_uv
msg_info "Setup Python3" msg_info "Setup Python3"
$STD apt-get update
$STD rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
$STD apt-get remove --purge -y python3.12 python3.12-dev python3.12-venv
$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
ln -sf /usr/bin/python3.13 /usr/bin/python3
msg_ok "Setup Python3" msg_ok "Setup Python3"
msg_info "Preparing Python 3.13 for uv"
$STD 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"
mkdir /srv/homeassistant rm -rf /srv/homeassistant
mkdir -p /srv/homeassistant
cd /srv/homeassistant cd /srv/homeassistant
python3 -m venv . $STD 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 python3 -m pip install webrtcvad wheel homeassistant mysqlclient psycopg2-binary isal $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"
@ -77,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"