@@ -21,8 +21,6 @@ catch_errors
2121
2222function update_script() {
2323 header_info
24-
25- # OS Check
2624 if ! lsb_release -d | grep -q " Ubuntu 24.10" ; then
2725 msg_error " Wrong OS detected. This script only supports Ubuntu 24.10."
2826 msg_error " Read Guide: https://github.com/community-scripts/ProxmoxVE/discussions/1549"
@@ -32,54 +30,88 @@ function update_script() {
3230 check_container_resources
3331 if [[ ! -d /srv/homeassistant ]]; then
3432 msg_error " No ${APP} Installation Found!"
35- exit
33+ exit 1
3634 fi
37- PY= $( ls /srv/homeassistant/lib/ )
35+ setup_uv
3836 IP=$( hostname -I | awk ' {print $1}' )
3937 UPD=$( whiptail --backtitle " Proxmox VE Helper Scripts" --title " UPDATE" --radiolist --cancel-button Exit-Script " Spacebar = Select" 11 58 4 \
4038 " 1" " Update Core" ON \
4139 " 2" " Install HACS" OFF \
4240 " 3" " Install FileBrowser" OFF \
4341 3>&1 1>&2 2>&3 )
42+
4443 if [ " $UPD " == " 1" ]; then
4544 if (whiptail --backtitle " Proxmox VE Helper Scripts" --defaultno --title " SELECT BRANCH" --yesno " Use Beta Branch?" 10 58); then
4645 clear
4746 header_info
4847 echo -e " ${GN} Updating to Beta Version${CL} "
49- BR=" --pre "
48+ BR=" --pre"
5049 else
5150 clear
5251 header_info
5352 echo -e " ${GN} Updating to Stable Version${CL} "
5453 BR=" "
5554 fi
55+
5656 msg_info " Stopping Home Assistant"
5757 systemctl stop homeassistant
5858 msg_ok " Stopped Home Assistant"
5959
60+ if [[ -d /srv/homeassistant/bin ]]; then
61+ msg_info " Migrating to .venv-based structure"
62+ $STD source /srv/homeassistant/bin/activate
63+ PY_VER=$( python3 -c " import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" )
64+ $STD deactivate
65+ mv /srv/homeassistant " /srv/homeassistant_backup_$PY_VER "
66+ mkdir -p /srv/homeassistant
67+ cd /srv/homeassistant
68+
69+ $STD uv python install 3.13
70+ UV_PYTHON=$( uv python list | awk ' /3\.13\.[0-9]+.*\/root\/.local/ {print $2; exit}' )
71+ if [[ -z " $UV_PYTHON " ]]; then
72+ msg_error " No local Python 3.13 found via uv"
73+ exit 1
74+ fi
75+
76+ $STD uv venv .venv --python " $UV_PYTHON "
77+ $STD source .venv/bin/activate
78+ $STD uv pip install homeassistant mysqlclient psycopg2-binary isal webrtcvad wheel
79+ mkdir -p /root/.homeassistant
80+ msg_ok " Migration complete"
81+ else
82+ source /srv/homeassistant/.venv/bin/activate
83+ fi
84+
6085 msg_info " Updating Home Assistant"
61- source /srv/homeassistant/bin/activate
62- $STD pip install ${BR} --upgrade homeassistant
86+ $STD uv pip install $BR --upgrade homeassistant
6387 msg_ok " Updated Home Assistant"
6488
6589 msg_info " Starting Home Assistant"
90+ if [[ -f /etc/systemd/system/homeassistant.service ]] && grep -q " /srv/homeassistant/bin/python3" /etc/systemd/system/homeassistant.service; then
91+ sed -i ' s|ExecStart=/srv/homeassistant/bin/python3|ExecStart=/srv/homeassistant/.venv/bin/python3|' /etc/systemd/system/homeassistant.service
92+ sed -i ' s|PATH=/srv/homeassistant/bin|PATH=/srv/homeassistant/.venv/bin|' /etc/systemd/system/homeassistant.service
93+ $STD systemctl daemon-reload
94+ fi
95+
6696 systemctl start homeassistant
67- sleep 2
97+ sleep 5
6898 msg_ok " Started Home Assistant"
6999 msg_ok " Update Successful"
70- echo -e " \n Go to http://${IP} :8123 \n "
100+ echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :8123${CL} "
71101 exit
72102 fi
103+
73104 if [ " $UPD " == " 2" ]; then
74105 msg_info " Installing Home Assistant Community Store (HACS)"
75106 $STD apt update
76107 $STD apt install -y unzip
77- cd .homeassistant
108+ cd /root/ .homeassistant
78109 $STD bash <( curl -fsSL https://get.hacs.xyz)
79110 msg_ok " Installed Home Assistant Community Store (HACS)"
80111 echo -e " \n Reboot Home Assistant and clear browser cache then Add HACS integration.\n"
81112 exit
82113 fi
114+
83115 if [ " $UPD " == " 3" ]; then
84116 set +Eeuo pipefail
85117 read -r -p " Would you like to use No Authentication? <y/N> " prompt
@@ -131,4 +163,4 @@ description
131163msg_ok " Completed Successfully!\n"
132164echo -e " ${CREATING}${GN}${APP} setup has been successfully initialized!${CL} "
133165echo -e " ${INFO}${YW} Access it using the following URL:${CL} "
134- echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :8123${CL} "
166+ echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :8123${CL} "
0 commit comments