You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
container-overlay/scripts/homeassistant/step/5-config.sh

61 lines
1.5 KiB

#
# Функция configure() настраивает Home Assistant
#
configure() {
# выйдем если все настроено
grep -q ^http: /etc/homeassistant/configuration.yaml &>/dev/null && return || true
local home_dir=/var/calculate/www/homeassistant
local live_dir="$home_dir/homeassistant-live"
local config_dir="/var/calculate/homeassistant"
if [[ -e $config_dir ]]; then
return
else
mkdir -p $config_dir
chmod 700 $config_dir
chown homeassistant: $config_dir
fi
su - homeassistant -s /bin/bash -c "$(cat <<- EOF
set -ueo pipefail
export PATH="/lib/rc/bin:$PATH"
source $live_dir/bin/activate
hass --config /etc/homeassistant >/dev/null &
id_hass=\$!
echo
einfon "Check for the first start Home Assistant "
while ! curl http://127.0.0.1:8123 2>/dev/null; do
echo -n .
sleep 1
done
kill \$id_hass
eend
EOF
)"
cat >> /etc/homeassistant/configuration.yaml << EOF
http:
server_host: 127.0.0.1
use_x_forwarded_for: true
trusted_proxies: 127.0.0.1
recorder:
db_url: postgresql://${ini[postgresql.homeassistant_user]}:${ini[postgresql.homeassistant_password]}@127.0.0.1/${ini[postgresql.homeassistant_database]}
panel_iframe:
zigbee:
title: Zigbee2mqtt
url: ${ini[homeassistant.protocol]}://${ini[homeassistant.domain]}/${ini[nginx.zigbee2mqtt_subpath]}
icon: mdi:zigbee
configurator:
title: Configurator
icon: mdi:wrench
url: ${ini[homeassistant.protocol]}://${ini[homeassistant.domain]}/${ini[nginx.hass-configurator_subpath]}
EOF
}