diff --git a/profiles/templates/homeassistant/homeassistant/data/.calculate_directory b/profiles/templates/homeassistant/homeassistant/data/.calculate_directory new file mode 100644 index 0000000..ec5a30b --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/data/.calculate_directory @@ -0,0 +1 @@ +# Calculate path=/var/calculate name=homeassistant chmod=700 chown=homeassistant:homeassistant diff --git a/profiles/templates/homeassistant/homeassistant/etc/homeassistant/.calculate_directory b/profiles/templates/homeassistant/homeassistant/etc/homeassistant/.calculate_directory deleted file mode 100644 index 2be8757..0000000 --- a/profiles/templates/homeassistant/homeassistant/etc/homeassistant/.calculate_directory +++ /dev/null @@ -1 +0,0 @@ -# Calculate chown=homeassistant:homeassistant diff --git a/profiles/templates/homeassistant/homeassistant/init.homeassistant b/profiles/templates/homeassistant/homeassistant/init.homeassistant index 2c0241e..df482bb 100644 --- a/profiles/templates/homeassistant/homeassistant/init.homeassistant +++ b/profiles/templates/homeassistant/homeassistant/init.homeassistant @@ -18,7 +18,7 @@ directory=/var/calculate/www/homeassistant start_stop_daemon_args="--user $user --stdout $stdoutlog --stderr $serverlog --wait 10" command_args=" - --config /etc/homeassistant + --config /var/calculate/homeassistant --log-file $warningslog --log-rotate-days 9 ${HASS_OPTS} diff --git a/profiles/templates/homeassistant/homeassistant/link.homeassistant b/profiles/templates/homeassistant/homeassistant/link.homeassistant new file mode 100644 index 0000000..34af040 --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/link.homeassistant @@ -0,0 +1 @@ +# Calculate path=/etc name=#-cut(1,.)-# link=/var/calculate/#-cut(1,.)-# symbolic protected diff --git a/profiles/templates/homeassistant/zigbee2mqtt/data/.calculate_directory b/profiles/templates/homeassistant/zigbee2mqtt/data/.calculate_directory new file mode 100644 index 0000000..37d838e --- /dev/null +++ b/profiles/templates/homeassistant/zigbee2mqtt/data/.calculate_directory @@ -0,0 +1 @@ +# Calculate path=/var/calculate name=zigbee2mqtt chmod=700 chown=zigbee2mqtt:zigbee2mqtt diff --git a/profiles/templates/homeassistant/zigbee2mqtt/link.zigbee2mqtt b/profiles/templates/homeassistant/zigbee2mqtt/link.zigbee2mqtt new file mode 100644 index 0000000..34af040 --- /dev/null +++ b/profiles/templates/homeassistant/zigbee2mqtt/link.zigbee2mqtt @@ -0,0 +1 @@ +# Calculate path=/etc name=#-cut(1,.)-# link=/var/calculate/#-cut(1,.)-# symbolic protected diff --git a/scripts/homeassistant/step/1-install.sh b/scripts/homeassistant/step/1-install.sh index c4abaf6..c1e1716 100755 --- a/scripts/homeassistant/step/1-install.sh +++ b/scripts/homeassistant/step/1-install.sh @@ -11,10 +11,11 @@ SCRIPT=$(readlink -f $0) . /var/db/repos/container/scripts/functions.sh . /var/db/repos/calculate/scripts/ini.sh +cd einfo 'Create a virtualenv' -python -m venv ~/homeassistant-live -. ~/homeassistant-live/bin/activate +python -m venv homeassistant-live +. homeassistant-live/bin/activate einfo 'Install all Python dependencies' python -m pip install wheel @@ -26,8 +27,8 @@ einfo 'Install PostgreSQL dependencies' pip install psycopg2 ha_ver=$(pip list | grep ^homeassistant | awk '{print $2}') -mv ~/homeassistant-live ~/versions/homeassistant-${ha_ver} -ln -s ~/versions/homeassistant-${ha_ver} ~/homeassistant-live +mv homeassistant-live versions/homeassistant-${ha_ver} +ln -sf versions/homeassistant-${ha_ver} homeassistant-live echo '. ~/homeassistant-live/bin/activate' >> ~/.bashrc echo '. ~/homeassistant-live/bin/activate' >> ~/.bash_profile diff --git a/scripts/homeassistant/step/3-zigbee2mqtt.sh b/scripts/homeassistant/step/3-zigbee2mqtt.sh index c86bf9b..e09e0ba 100755 --- a/scripts/homeassistant/step/3-zigbee2mqtt.sh +++ b/scripts/homeassistant/step/3-zigbee2mqtt.sh @@ -14,12 +14,20 @@ SCRIPT=$(readlink -f $0) cd ver=$(curl -s https://api.github.com/repos/Koenkk/zigbee2mqtt/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest Zigbee2MQTT version is ${ver}" +[[ -z $ver ]] && eerror 'The latest version of zigbee2mqtt is not defined!' + wget -q https://github.com/Koenkk/zigbee2mqtt/archive/refs/tags/${ver}.zip -O zigbee2mqtt-${ver}.zip einfo 'Extract the archive' unzip -q -d versions zigbee2mqtt-${ver}.zip rm zigbee2mqtt-${ver}.zip ln -sf versions/zigbee2mqtt-${ver} zigbee2mqtt-live +if [[ -n "$(ls -A /var/calculate/zigbee2mqtt)" ]]; then + mv versions/zigbee2mqtt-${ver}/data/* /var/calculate/zigbee2mqtt + rmdir versions/zigbee2mqtt-${ver}/data + ln -s /var/calculate/zigbee2mqtt versions/zigbee2mqtt-${ver}/data +fi + einfo 'Install python env' python -m venv zigbee2mqtt-live/.venv