From 9428e71b08d82f4820f83340dedfeb174b3fb6bf Mon Sep 17 00:00:00 2001 From: Alexander Tratsevskiy Date: Fri, 28 Apr 2023 16:47:38 +0300 Subject: [PATCH] =?UTF-8?q?homeassistant:=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/homeassistant/setup.sh | 23 +++++++++++++++---- scripts/homeassistant/step/1-install.sh | 2 +- scripts/homeassistant/step/2-postgresql.sh | 2 +- scripts/homeassistant/step/3-zigbee2mqtt.sh | 4 ++-- .../homeassistant/step/4-hass-configurator.sh | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/scripts/homeassistant/setup.sh b/scripts/homeassistant/setup.sh index 26566f8..b9f8f6a 100755 --- a/scripts/homeassistant/setup.sh +++ b/scripts/homeassistant/setup.sh @@ -7,10 +7,27 @@ source /var/db/repos/calculate/scripts/ini.sh source /var/db/repos/container/scripts/functions.sh script_path=$(dirname $(readlink -f $0)) +if [[ ! -e /var/calculate/homeassistant ]]; then + first_start=1 +else + first_start= +fi + log_dir=/var/log/calculate/cl-setup rm -rf $log_dir mkdir -p $log_dir +if [[ $first_start && ! -e /dev/ttyUSB0 && ! -e /dev/ttyACM0 ]]; then + while true; do + read -p "Zigbee2MQTT device is not found, the configuration will be done without Zigbee to MQTT bridge (y/n)? " answer + case $answer in + [Yy]* ) break; exit ;; + [Nn]* ) exit ;; + * ) echo "Please answer yes or no." ;; + esac + done +fi + # Установка/настройка и проверка обновлений configurate() { local check=${1:-} @@ -30,7 +47,7 @@ configurate() { } -if [[ ! -e /var/calculate/homeassistant ]]; then +if [[ $first_start ]]; then configurate echo 'Launch preparation' @@ -43,9 +60,7 @@ if [[ ! -e /var/calculate/homeassistant ]]; then openrc >>$log_dir/setup.log eend - echo "All is done! Open the link \ - ${ini[homeassistant.protocol]}://${ini[homeassistant.domain]} \ - on your browser." + echo "All is done! Open the link ${ini[homeassistant.protocol]}://${ini[homeassistant.domain]} on your browser." else configurate check && { echo 'No updates available.' diff --git a/scripts/homeassistant/step/1-install.sh b/scripts/homeassistant/step/1-install.sh index 5c642ef..e30d44b 100644 --- a/scripts/homeassistant/step/1-install.sh +++ b/scripts/homeassistant/step/1-install.sh @@ -19,7 +19,7 @@ configure() { einfo "homeassistant: $last_ver update available, $live_ver installed" eval $__result=1 # наличие обновления fi - return + return 0 fi if [[ ! -e $home_dir ]]; then diff --git a/scripts/homeassistant/step/2-postgresql.sh b/scripts/homeassistant/step/2-postgresql.sh index 8231d13..b0e69d2 100644 --- a/scripts/homeassistant/step/2-postgresql.sh +++ b/scripts/homeassistant/step/2-postgresql.sh @@ -3,7 +3,7 @@ # configure() { if [[ -n "$(ls -A /var/lib/postgresql)" ]]; then - return + return 0 fi echo 'Setting up PostgreSQL' diff --git a/scripts/homeassistant/step/3-zigbee2mqtt.sh b/scripts/homeassistant/step/3-zigbee2mqtt.sh index 098bbad..a3f83c2 100644 --- a/scripts/homeassistant/step/3-zigbee2mqtt.sh +++ b/scripts/homeassistant/step/3-zigbee2mqtt.sh @@ -22,7 +22,7 @@ configure() { einfo "zigbee2mqtt: $last_ver update available, $live_ver installed" eval $__result=1 # наличие обновления fi - return + return 0 fi # проверим на наличие устройства если сервис еще не настроен @@ -32,7 +32,7 @@ configure() { elif [[ -e /dev/ttyACM0 ]]; then local file_dev=/dev/ttyACM0 else - return + return 0 fi fi diff --git a/scripts/homeassistant/step/4-hass-configurator.sh b/scripts/homeassistant/step/4-hass-configurator.sh index 03b0008..7a7c32f 100644 --- a/scripts/homeassistant/step/4-hass-configurator.sh +++ b/scripts/homeassistant/step/4-hass-configurator.sh @@ -21,7 +21,7 @@ configure() { einfo "hass-configurator: $last_ver update available, $live_ver installed" eval $__result=1 # наличие обновления fi - return + return 0 fi if [[ ! -e $home_dir ]]; then