Update homeassistant-core.sh

This commit is contained in:
CanbiZ 2025-05-09 11:07:35 +02:00
parent ab30ef5296
commit 9066e58171

View File

@ -28,19 +28,22 @@ function update_script() {
msg_error "Read Guide: https://github.com/community-scripts/ProxmoxVE/discussions/1549" msg_error "Read Guide: https://github.com/community-scripts/ProxmoxVE/discussions/1549"
exit 1 exit 1
fi fi
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /srv/homeassistant ]]; then if [[ ! -d /srv/homeassistant ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit 1
fi fi
PY=$(ls /srv/homeassistant/lib/) setup_uv
IP=$(hostname -I | awk '{print $1}') IP=$(hostname -I | awk '{print $1}')
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \
"1" "Update Core" ON \ "1" "Update Core" ON \
"2" "Install HACS" OFF \ "2" "Install HACS" OFF \
"3" "Install FileBrowser" OFF \ "3" "Install FileBrowser" OFF \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
if [ "$UPD" == "1" ]; then if [ "$UPD" == "1" ]; then
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SELECT BRANCH" --yesno "Use Beta Branch?" 10 58); then if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SELECT BRANCH" --yesno "Use Beta Branch?" 10 58); then
clear clear
@ -53,13 +56,38 @@ function update_script() {
echo -e "${GN}Updating to Stable Version${CL}" echo -e "${GN}Updating to Stable Version${CL}"
BR="" BR=""
fi fi
msg_info "Stopping Home Assistant" msg_info "Stopping Home Assistant"
systemctl stop homeassistant systemctl stop homeassistant
msg_ok "Stopped Home Assistant" msg_ok "Stopped Home Assistant"
msg_info "Updating Home Assistant" if [[ -d /srv/homeassistant/bin ]]; then
msg_info "Migrating to .venv-based structure"
source /srv/homeassistant/bin/activate source /srv/homeassistant/bin/activate
$STD pip install ${BR}--upgrade homeassistant PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
deactivate
mv /srv/homeassistant "/srv/homeassistant_backup_$PY_VER"
mkdir -p /srv/homeassistant
cd /srv/homeassistant
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
uv venv .venv --python "$UV_PYTHON"
source .venv/bin/activate
uv pip install homeassistant mysqlclient psycopg2-binary isal webrtcvad wheel
mkdir -p /root/.homeassistant
msg_ok "Migration complete"
else
source /srv/homeassistant/.venv/bin/activate
fi
msg_info "Updating Home Assistant"
$STD uv pip install $BR --upgrade homeassistant
msg_ok "Updated Home Assistant" msg_ok "Updated Home Assistant"
msg_info "Starting Home Assistant" msg_info "Starting Home Assistant"
@ -70,16 +98,18 @@ function update_script() {
echo -e "\n Go to http://${IP}:8123 \n" echo -e "\n Go to http://${IP}:8123 \n"
exit exit
fi fi
if [ "$UPD" == "2" ]; then if [ "$UPD" == "2" ]; then
msg_info "Installing Home Assistant Community Store (HACS)" msg_info "Installing Home Assistant Community Store (HACS)"
$STD apt update $STD apt update
$STD apt install -y unzip $STD apt install -y unzip
cd .homeassistant cd /root/.homeassistant
$STD bash <(curl -fsSL https://get.hacs.xyz) $STD bash <(curl -fsSL https://get.hacs.xyz)
msg_ok "Installed Home Assistant Community Store (HACS)" msg_ok "Installed Home Assistant Community Store (HACS)"
echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n" echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n"
exit exit
fi fi
if [ "$UPD" == "3" ]; then if [ "$UPD" == "3" ]; then
set +Eeuo pipefail set +Eeuo pipefail
read -r -p "Would you like to use No Authentication? <y/N> " prompt read -r -p "Would you like to use No Authentication? <y/N> " prompt