Skip to content

Commit

Permalink
v8.15
Browse files Browse the repository at this point in the history
- DietPi-Software | Home Assistant: Our Home Assistant integration used two Python environments: A pyenv is used to install the "homeassistant" core module and its direct dependencies. Home Assistant itself installs its frontend with dependencies on startup, as well as dependencies for integrations on demand, internally into another Python environment. On Home Assistant reinstalls, pyenv is removed but the internal dependencies were left untouched. This caused issues when those dependency builds were incompatible with the new pyenv Python version, or conflicting with other pyenv module upgrades. Both environments are now merged and reset on every reinstall, which solves potential conflicts but means that the first Home Assistant startup after a reinstall takes longer. Many thanks to @maury77 for reporting a related issue: #6117
  • Loading branch information
MichaIng committed Feb 18, 2023
1 parent afead46 commit a677610
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ v8.15
Enhancements:
- DietPi-Installer | Resolved an issue where conflicting network configurations were left in place, e.g. from cloud-init when running the script on a VPS Debian image. Many thanks to @mews-se for reporting this issue: https://github.com/MichaIng/DietPi/issues/6067
- DietPi-Software | XRDP: TLS via snakeoil certificate is now enabled OOTB. This leads to a warning shown on Windows RDP clients until either a proper certificate signed by a trusted CA is used (e.g. by Let's Encrypt), or it is muted for the particular server via checkbox at the client. Many thanks to @amibumping for providing the needed step: https://github.com/MichaIng/DietPi/issues/5976
- DietPi-Software | Home Assistant: Our Home Assistant integration used two Python environments: A pyenv is used to install the "homeassistant" core module and its direct dependencies. Home Assistant itself installs its frontend with dependencies on startup, as well as dependencies for integrations on demand, internally into another Python environment. On Home Assistant reinstalls, pyenv is removed but the internal dependencies were left untouched. This caused issues when those dependency builds were incompatible with the new pyenv Python version, or conflicting with other pyenv module upgrades. Both environments are now merged and reset on every reinstall, which solves potential conflicts but means that the first Home Assistant startup after a reinstall takes longer. Many thanks to @maury77 for reporting a related issue: https://github.com/MichaIng/DietPi/issues/6117

Bug fixes:
- Quartz64 | Resolved an issue where the system boots read-only on very first boot. Many thanks to @belveder79 for reporting this issue: https://github.com/MichaIng/DietPi/issues/6149
Expand Down
32 changes: 18 additions & 14 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -11072,7 +11072,6 @@ _EOF_
G_EXEC chown "$ha_user:$ha_user" "$ha_home"
if [[ $G_HW_ARCH == [12] ]]
then
G_EXEC mkdir -p "$ha_home/.pip"
# libjpeg-dev for Pillow, libatlas-base-dev for numpy
aDEPS+=('libjpeg-dev' 'libatlas-base-dev')
# Rust for cryptography
Expand All @@ -11090,6 +11089,23 @@ _EOF_
[[ -d '/srv/homeassistant' ]] && G_EXEC rm -R /srv/homeassistant # pre-v6-27
G_EXEC mv pyenv-master "$ha_home/.pyenv"

# Link config and data to DietPi userdata
if [[ ! -d '/mnt/dietpi_userdata/homeassistant' ]]
then
if [[ -d $ha_home/.homeassistant ]]
then
G_EXEC mv "$ha_home/.homeassistant" /mnt/dietpi_userdata/homeassistant
else
G_EXEC mkdir /mnt/dietpi_userdata/homeassistant
fi
fi
[[ -d $ha_home/.homeassistant ]] && G_EXEC rm -R "$ha_home/.homeassistant"
G_EXEC ln -sf /mnt/dietpi_userdata/homeassistant "$ha_home/.homeassistant"

# Reset and merge pyenv and HA Python environment to avoid version mismatches on Python upgrades: https://github.com/MichaIng/DietPi/issues/6117
[[ -d '/mnt/dietpi_userdata/homeassistant/deps' ]] && G_EXEC rm -R /mnt/dietpi_userdata/homeassistant/deps
G_EXEC ln -sf "$ha_home/.pyenv/versions/$ha_python_version" /mnt/dietpi_userdata/homeassistant/deps

# Generate script to activate pyenv: This must be sourced from the originating shell, hence it does not require execute permissions.
echo "#!/bin/dash
if [ \$(whoami) != '$ha_user' ]; then
Expand Down Expand Up @@ -11123,6 +11139,7 @@ exec hass -c '/mnt/dietpi_userdata/homeassistant'" > "$ha_home/homeassistant-sta
exec sudo -u $ha_user dash -c '$ha_pyenv_activation; exec pip3 install --no-cache-dir -U homeassistant'" > "$ha_home/homeassistant-update.sh"
G_EXEC chmod +x "$ha_home/homeassistant-update.sh"

# Service
cat << _EOF_ > /etc/systemd/system/home-assistant.service
[Unit]
Description=Home Assistant (DietPi)
Expand All @@ -11138,19 +11155,6 @@ RestartForceExitStatus=100
[Install]
WantedBy=multi-user.target
_EOF_
# Link config and data to DietPi userdata
if [[ ! -d '/mnt/dietpi_userdata/homeassistant' ]]
then
if [[ -d '/home/homeassistant/.homeassistant' ]]
then
G_EXEC mv "$ha_home/.homeassistant" /mnt/dietpi_userdata/homeassistant
else
G_EXEC mkdir /mnt/dietpi_userdata/homeassistant
fi
fi
[[ -d $ha_home/.homeassistant ]] && G_EXEC rm -R "$ha_home/.homeassistant"
G_EXEC ln -s /mnt/dietpi_userdata/homeassistant "$ha_home/.homeassistant"

# Download HACS
Download_Install 'https://github.com/hacs/integration/releases/latest/download/hacs.zip' hacs
[[ -d '/mnt/dietpi_userdata/homeassistant/custom_components/hacs' ]] && G_EXEC rm -R /mnt/dietpi_userdata/homeassistant/custom_components/hacs
Expand Down

0 comments on commit a677610

Please sign in to comment.