homeassistant: обновлена настройка

master
parent 013c7763dc
commit b29c6c1920

@ -9,3 +9,25 @@ taiga_user = taiga
[rabbitmq]
taiga_user = taiga
# for a self-signed certificate
[req]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = some_dn
[some_dn]
C = RU
L = Saint-Petersburg
O = Calculate Linux
emailAddress = support@calculate.ru
CN = calculate-linux.org
[req_ext]
subjectAltName = @alt_names
[alt_names]
DNS.1 = otherdomain.com
IP.1 = 1.2.3.4

@ -0,0 +1,7 @@
# Calculate path=/etc/conf.d name=#-cut(1,.)-# format=openrc
# /etc/conf.d/homeassistant: configuration for /etc/init.d/homeassistant
# Switches to pass to hass. See 'hass --help' for
# a description of the possible switches.
#
HASS_OPTS=""

@ -1,26 +1,4 @@
# Calculate format=samba path=/var/calculate chmod=600 grep(/var/calculate/ini.env,homeassistant_sites_domain)== protected
# Calculate format=samba path=/var/calculate grep(/var/calculate/ini.env,homeassistant_sites_domain)== protected
[homeassistant]
protocol = http
domain = home.example.org
# for a self-signed certificate
[req]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = some_dn
[some_dn]
C = RU
L = Saint-Petersburg
O = Calculate Linux
emailAddress = support@calculate.ru
CN = calculate-linux.org
[req_ext]
subjectAltName = @alt_names
[alt_names]
DNS.1 = otherdomain.com
IP.1 = 1.2.3.4
domain = #-ip()-#

@ -12,7 +12,7 @@ serverlog="/var/log/homeassistant/server.log"
warningslog="/var/log/homeassistant/warnings.log"
retry="20"
command=/var/calculate/www/homeassistant/.venv-live/bin/hass
command=/var/calculate/www/homeassistant/homeassistant-live/bin/hass
directory=/var/calculate/www/homeassistant
start_stop_daemon_args="--user $user --stdout $stdoutlog --stderr $serverlog --wait 10"

@ -1,10 +0,0 @@
# Calculate run=/bin/bash grep(/var/calculate/ini.env,home\.example.org)!=
# Подставим IP eth0, пока у шаблонов нет необходимой функции
interface=$(ip route | grep -m 1 'default via' | awk '{print $5}')
if [[ -z $interface ]]
then
interface=eth0
fi
IP=$(ifconfig $interface 2>/dev/null | grep 'inet ' | awk '{print $2}')
sed -i -E "s/(domain =).*/\1 $IP/g" /var/calculate/ini.env

@ -0,0 +1,3 @@
# Calculate path=/etc name=group format=patch protected
<reg>dialout:x:20:homeassistant</reg>
<text>dialout:x:20:homeassistant,zigbee2mqtt</text>

@ -1,4 +1,9 @@
# Calculate format=samba path=/var/calculate chmod=600 grep(/var/calculate/ini.env,zigbee2mqtt)== protected
[zigbee2mqtt]
#?exists(/dev/ttyUSB0)-#
dev = /dev/ttyUSB0
#exists#
#?exists(/dev/ttyACM0)-#
dev = /dev/ttyACM0
#exists#
nodeenv = 16.15.0

@ -0,0 +1,33 @@
# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=# exists(/var/calculate/www/zigbee2mqtt/zigbee2mqtt-live)!=
#!/sbin/openrc-run
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
description="Allows you to use your Zigbee devices without the vendor's bridge or gateway"
user="zigbee2mqtt"
group="zigbee2mqtt"
command="/var/calculate/www/zigbee2mqtt/zigbee2mqtt-live/.venv/bin/npm"
directory="/var/calculate/www/${RC_SVCNAME}/${RC_SVCNAME}-live"
command_args="start"
command_user="${user}:${group}"
command_background="yes"
pidfile="/run/${RC_SVCNAME}.pid"
output_log="/var/log/${RC_SVCNAME}.log"
error_log="${output_log}"
export PATH="/var/calculate/www/zigbee2mqtt/zigbee2mqtt-live/.venv/bin:$PATH"
depend() {
need mosquitto
}
stop(){
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --stop --quiet --retry 20 --pidfile $pidfile
eend $?
}
start_pre() {
checkpath --file --owner $user --mode 0644 $output_log
}

@ -0,0 +1 @@
# Calculate path=/etc/runlevels/default name=#-cut(1,.)-# link=/etc/init.d/#-cut(1,.)-# protected symbolic exists(/var/calculate/www/zigbee2mqtt/zigbee2mqtt-live)!=

@ -0,0 +1,10 @@
#!/bin/bash
# Define the IP address
interface=$(ip route | grep -m 1 'default via' | awk '{print $5}')
if [[ -z $interface ]]
then
interface=eth0
fi
IP=$(ifconfig $interface 2>/dev/null | grep 'inet ' | awk '{print $2}')
echo $IP

@ -6,16 +6,16 @@ scriptpath=$(dirname $(readlink -f $0))
. /var/db/repos/calculate/scripts/ini.sh
chmod o+rw /var/calculate/ini.env
chmod o+r /var/calculate/ini.env
for script in $scriptpath/step/*.sh; do
"$script"
done
chmod o-rw /var/calculate/ini.env
if [[ ! -e /etc/runlevels/default/homeassistant ]]; then
cl-setup-system
rc-update -u
fi
openrc
chmod 600 /var/calculate/ini.env
echo -e "\nAll is done! Open the link ${ini[homeassistant.protocol]}://${ini[homeassistant.domain]} on your browser."

@ -3,20 +3,18 @@
set -ueo pipefail
export PATH="/lib/rc/bin:$PATH"
test -e ~/homeassistant-live && exit
SCRIPT=$(readlink -f $0)
[[ $UID == 0 ]] && exec su - homeassistant -c "$SCRIPT"
. /var/db/repos/container/scripts/functions.sh
. /var/db/repos/calculate/scripts/ini.sh
if [[ ! -e ~/.venv-live ]]; then
einfo 'Create a virtualenv'
python -m venv ~/.venv-live
echo '. ~/.venv-live/bin/activate' >> ~/.bashrc
echo '. ~/.venv-live/bin/activate' >> ~/.bash_profile
. ~/.venv-live/bin/activate
python -m venv ~/homeassistant-live
. ~/homeassistant-live/bin/activate
einfo 'Install all Python dependencies'
python -m pip install wheel
@ -28,6 +26,8 @@ if [[ ! -e ~/.venv-live ]]; then
pip install psycopg2
ha_ver=$(pip list | grep ^homeassistant | awk '{print $2}')
mv ~/.venv-live ~/.venv-${ha_ver}
ln -s ~/.venv-${ha_ver} ~/.venv-live
fi
mv ~/homeassistant-live ~/versions/homeassistant-${ha_ver}
ln -s ~/versions/homeassistant-${ha_ver} ~/homeassistant-live
echo '. ~/homeassistant-live/bin/activate' >> ~/.bashrc
echo '. ~/homeassistant-live/bin/activate' >> ~/.bash_profile

@ -1,17 +1,18 @@
#!/bin/bash
# Guide: https://www.zigbee2mqtt.io/guide/installation/07_python_virtual_environment.html
set -ueo pipefail
export PATH="/lib/rc/bin:$PATH"
test -e ~/zigbee2mqtt-live && exit
SCRIPT=$(readlink -f $0)
[[ $UID == 0 ]] && exec su - zigbee2mqtt -c "$SCRIPT"
. /var/db/repos/container/scripts/functions.sh
. /var/db/repos/calculate/scripts/ini.sh
if [[ ! -e ~/zigbee2mqtt-live ]]; then
cd
einfo 'Clone Zigbee2MQTT repository'
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}"
wget -q https://github.com/Koenkk/zigbee2mqtt/archive/refs/tags/${ver}.zip -O zigbee2mqtt-${ver}.zip
einfo 'Extract the archive'
@ -42,7 +43,7 @@ if [[ ! -e ~/zigbee2mqtt-live ]]; then
echo '. ~/zigbee2mqtt-live/.venv/bin/activate' >> .bashrc
echo '. ~/zigbee2mqtt-live/.venv/bin/activate' >> .bash_profile
einfo 'Setup zigbee2mqtt'
ebegin 'Setup zigbee2mqtt'
mv zigbee2mqtt-live/data/configuration.yaml zigbee2mqtt-live/data/configuration.yaml.old
cat > zigbee2mqtt-live/data/configuration.yaml << EOF
# Home Assistant integration (MQTT discovery)
@ -58,12 +59,13 @@ mqtt:
# MQTT server URL
server: 'mqtt://localhost'
# MQTT server authentication, uncomment if required:
# # user: my_user
# user: my_user
# password: my_password
# Serial settings
serial:
# Location of USB sniffer
port: ${ini[zigbee2mqtt.dev]}
frontend: true
EOF
fi
eend

@ -3,9 +3,11 @@
set -ueo pipefail
export PATH="/lib/rc/bin:$PATH"
test -e /etc/homeassistant/configuration.yaml && exit
SCRIPT=$(readlink -f $0)
[[ $UID == 0 ]] && exec su - homeassistant -c "$SCRIPT"
source .venv-live/bin/activate
. homeassistant-live/bin/activate
. /var/db/repos/container/scripts/functions.sh
. /var/db/repos/calculate/scripts/ini.sh

Loading…
Cancel
Save