homeassistant: исправления

- исправлено обновление когда не настроен zigbee2mqtt
- добавлена проверка открытого порта postgresql
master
parent a7b14c33bd
commit 2de0e68682

@ -1,5 +1,5 @@
# Clear stdin before reading
clear_buf(){
clear_buf() {
while read -r -t 0
do read -r
done
@ -7,7 +7,7 @@ clear_buf(){
}
# Convert ini.env array to Python list
arr_to_list(){
arr_to_list() {
if [[ $# == 0 || -z $1 ]]
then
echo "[]"
@ -28,7 +28,7 @@ arr_to_list(){
echo $list
}
get_last_ver(){
get_last_ver() {
local project=$1
local hosting=$2
case $hosting in
@ -41,10 +41,27 @@ get_last_ver(){
esac
}
get_live_ver(){
get_live_ver() {
if [[ ! -e $1 ]]; then
exit
fi
local current_ver=$(readlink -f $1)
echo ${current_ver##*-}
}
check_open_port() {
local check_port=$1
if which ss &>/dev/null; then
if ss -ltn | grep -q "^LISTEN.*:${check_port}\s"; then
return 0
else
return 1
fi
elif which netstat &>/dev/null; then
if netstat -nlt | grep -qE "${check_port}\s+[^\s]+\s+LISTEN"; then
return 0
else
return 1
fi
fi
}

@ -17,6 +17,7 @@ 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
@ -26,6 +27,11 @@ if [[ $first_start && ! -e /dev/ttyUSB0 && ! -e /dev/ttyACM0 ]]; then
* ) echo "Please answer yes or no." ;;
esac
done
if check_open_port 5432; then
echo Error: PostgreSQL port is busy.
exit 1
fi
fi
# Установка/настройка и проверка обновлений

@ -17,7 +17,7 @@ configure() {
# отобразим наличие обновления и выйдем
if [[ $action == 'check' ]]; then
if [[ $live_ver != $last_ver ]]; then
if [[ $live_ver && $live_ver != $last_ver ]]; then
einfo "homeassistant: $last_ver update available, $live_ver installed"
eval $__result=1
fi

@ -19,7 +19,7 @@ configure() {
# отобразим наличие обновления и выйдем
if [[ $action == 'check' ]]; then
if [[ $live_ver != $last_ver ]]; then
if [[ $live_ver && $live_ver != $last_ver ]]; then
einfo "zigbee2mqtt: $last_ver update available, $live_ver installed"
eval $__result=1
fi

@ -18,7 +18,7 @@ configure() {
# отобразим наличие обновления и выйдем
if [[ $action == 'check' ]]; then
if [[ $live_ver != $last_ver ]]; then
if [[ $live_ver && $live_ver != $last_ver ]]; then
einfo "hass-configurator: $last_ver update available, $live_ver installed"
eval $__result=1
fi

Loading…
Cancel
Save