parent
85efd3e2e3
commit
9a1a418f7a
@ -1,2 +1,2 @@
|
|||||||
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
|
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
|
||||||
hass-configurator:x:997:997:Filesystem-browser and text-editor:/var/calculate/www/hass-configurator:/bin/bash
|
hass-configurator:x:997:997:Filesystem-browser and text-editor:/var/calculate/www/hass-configurator:/sbin/nologin
|
||||||
|
@ -1 +0,0 @@
|
|||||||
# Calculate path=/var/calculate name=hass-configurator chmod=700 chown=hass-configurator:hass-configurator
|
|
@ -1 +0,0 @@
|
|||||||
# Calculate path=/var/calculate
|
|
@ -1 +0,0 @@
|
|||||||
# Calculate chmod=700 chown=hass-configurator:hass-configurator
|
|
@ -1,2 +1,2 @@
|
|||||||
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
|
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
|
||||||
homeassistant:x:999:999:Home Assistant Program User:/var/calculate/www/homeassistant:/bin/bash
|
homeassistant:x:999:999:Home Assistant Program User:/var/calculate/www/homeassistant:/sbin/nologin
|
||||||
|
@ -1 +0,0 @@
|
|||||||
# Calculate path=/var/calculate name=homeassistant chmod=700 chown=homeassistant:homeassistant
|
|
@ -1 +0,0 @@
|
|||||||
# Calculate path=/var/calculate
|
|
@ -1 +0,0 @@
|
|||||||
# Calculate chmod=700 chown=homeassistant:homeassistant
|
|
@ -1 +0,0 @@
|
|||||||
# Calculate chown=homeassistant:homeassistant
|
|
@ -1,5 +1,6 @@
|
|||||||
# Calculate env=update ac_update_sync==on path=/var/lib/portage cl_update_world==merge||cl_update_world==rebuild format=world
|
# Calculate env=update ac_update_sync==on path=/var/lib/portage cl_update_world==merge||cl_update_world==rebuild format=world
|
||||||
app-arch/unzip
|
app-arch/unzip
|
||||||
|
app-misc/jq
|
||||||
app-misc/mosquitto
|
app-misc/mosquitto
|
||||||
dev-db/postgresql
|
dev-db/postgresql
|
||||||
www-servers/nginx
|
www-servers/nginx
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
|
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
|
||||||
zigbee2mqtt:x:998:998:A user for zigbee2mqtt:/var/calculate/www/zigbee2mqtt:/bin/bash
|
zigbee2mqtt:x:998:998:A user for zigbee2mqtt:/var/calculate/www/zigbee2mqtt:/sbin/nologin
|
||||||
|
@ -1 +0,0 @@
|
|||||||
# Calculate path=/var/calculate name=zigbee2mqtt chmod=700 chown=zigbee2mqtt:zigbee2mqtt
|
|
@ -1 +0,0 @@
|
|||||||
# Calculate path=/var/calculate
|
|
@ -1 +0,0 @@
|
|||||||
# Calculate chmod=700 chown=zigbee2mqtt:zigbee2mqtt
|
|
@ -1,34 +1,71 @@
|
|||||||
#!/bin/bash
|
#
|
||||||
|
# Функция configure() устанавливает Home Assistant
|
||||||
|
#
|
||||||
|
# Параметры:
|
||||||
|
# $1 = check - проверка обновлений, в противном случае установка или обновление
|
||||||
|
# $2 - возвращает имя модуля для перезагрузки в случае выполненного обновления
|
||||||
|
configure() {
|
||||||
|
local action=$1
|
||||||
|
local __result=$2
|
||||||
|
|
||||||
set -ueo pipefail
|
local home_dir=/var/calculate/www/homeassistant
|
||||||
export PATH="/lib/rc/bin:$PATH"
|
local last_ver="$(get_last_ver homeassistant pip)"
|
||||||
|
local work_dir="$home_dir/versions/homeassistant-$last_ver"
|
||||||
|
local live_dir="$home_dir/homeassistant-live"
|
||||||
|
local live_ver="$(get_live_ver $live_dir)"
|
||||||
|
|
||||||
|
if [[ $action == 'check' ]]; then
|
||||||
|
if [[ $live_ver == $last_ver ]]; then
|
||||||
|
einfo "homeassistant: the latest version is installed $live_ver"
|
||||||
|
else
|
||||||
|
einfo "homeassistant: $last_ver update available, $live_ver installed"
|
||||||
|
eval $__result=1 # наличие обновления
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
test -e ~/homeassistant-live && exit
|
if [[ ! -e $home_dir ]]; then
|
||||||
|
mkdir -p $home_dir/versions
|
||||||
SCRIPT=$(readlink -f $0)
|
chmod 700 $home_dir
|
||||||
[[ $UID == 0 ]] && exec su - homeassistant -c "$SCRIPT"
|
chown homeassistant: $home_dir
|
||||||
|
fi
|
||||||
. /var/db/repos/container/scripts/functions.sh
|
|
||||||
. /var/db/repos/calculate/scripts/ini.sh
|
if [[ $live_ver != $last_ver ]]; then
|
||||||
|
if [[ $live_ver != '' ]]; then
|
||||||
cd
|
echo Update Home Assistant
|
||||||
einfo 'Create a virtualenv'
|
else
|
||||||
|
echo Install Home Assistant
|
||||||
python -m venv homeassistant-live
|
fi
|
||||||
. homeassistant-live/bin/activate
|
|
||||||
|
su - homeassistant -s /bin/bash -c "$(cat <<- EOF
|
||||||
einfo 'Install all Python dependencies'
|
set -ueo pipefail
|
||||||
python -m pip install wheel
|
export PATH="/lib/rc/bin:$PATH"
|
||||||
|
|
||||||
einfo 'Install Home Assistant'
|
ebegin 'Create a virtualenv'
|
||||||
pip install homeassistant
|
test -e $work_dir && rm -rf $work_dir
|
||||||
|
python -m venv $work_dir
|
||||||
einfo 'Install PostgreSQL dependencies'
|
source $work_dir/bin/activate
|
||||||
pip install psycopg2
|
eend
|
||||||
|
|
||||||
ha_ver=$(pip list | grep ^homeassistant | awk '{print $2}')
|
ebegin 'Install all Python dependencies'
|
||||||
mv homeassistant-live versions/homeassistant-${ha_ver}
|
python -m pip install wheel &>>/tmp/homeassistant.log
|
||||||
ln -sf versions/homeassistant-${ha_ver} homeassistant-live
|
eend
|
||||||
|
|
||||||
echo '. ~/homeassistant-live/bin/activate' >> ~/.bashrc
|
ebegin 'Install Home Assistant $last_ver'
|
||||||
echo '. ~/homeassistant-live/bin/activate' >> ~/.bash_profile
|
pip install homeassistant==$last_ver &>>/tmp/homeassistant.log
|
||||||
|
eend
|
||||||
|
|
||||||
|
ebegin 'Install PostgreSQL dependencies'
|
||||||
|
pip install psycopg2 &>>/tmp/homeassistant.log
|
||||||
|
eend
|
||||||
|
|
||||||
|
rm -f $live_dir
|
||||||
|
ln -s $work_dir $live_dir
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [[ $live_ver != '' ]]; then
|
||||||
|
eval $__result=homeassistant # демон который следует перезагрузить
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
#!/bin/bash
|
#
|
||||||
|
# Функция configure() настраивает PostgreSQL
|
||||||
|
#
|
||||||
|
# Параметры:
|
||||||
|
# $1 = check - пропуск настройки
|
||||||
|
configure() {
|
||||||
|
if [[ -n "$(ls -A /var/lib/postgresql)" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
set -ueo pipefail
|
emerge --config postgresql
|
||||||
|
|
||||||
[[ -n "$(ls -A /var/lib/postgresql)" ]] && exit
|
pg_ver=$(ls /etc/init.d/postgresql-*); pg_ver=${pg_ver##*-}
|
||||||
|
|
||||||
export PATH="/lib/rc/bin:$PATH"
|
/etc/init.d/postgresql-$pg_ver start
|
||||||
|
|
||||||
. /var/db/repos/container/scripts/functions.sh
|
psql -U postgres -c "ALTER USER postgres WITH PASSWORD '${ini[postgresql.postgres_password]}'"
|
||||||
. /var/db/repos/calculate/scripts/ini.sh
|
createuser -U postgres ${ini[postgresql.homeassistant_user]}
|
||||||
|
createdb -U postgres ${ini[postgresql.homeassistant_database]} -O ${ini[postgresql.homeassistant_user]}
|
||||||
|
psql -U postgres -c "ALTER USER ${ini[postgresql.homeassistant_user]} WITH PASSWORD '${ini[postgresql.homeassistant_password]}'"
|
||||||
|
|
||||||
emerge --config postgresql
|
cl-core-setup -n postgresql -f
|
||||||
|
|
||||||
pg_ver=$(ls /etc/init.d/postgresql-*); pg_ver=${pg_ver##*-}
|
/etc/init.d/postgresql-$pg_ver restart
|
||||||
|
}
|
||||||
/etc/init.d/postgresql-$pg_ver start
|
|
||||||
|
|
||||||
psql -U postgres -c "ALTER USER postgres WITH PASSWORD '${ini[postgresql.postgres_password]}'"
|
|
||||||
createuser -U postgres ${ini[postgresql.homeassistant_user]}
|
|
||||||
createdb -U postgres ${ini[postgresql.homeassistant_database]} -O ${ini[postgresql.homeassistant_user]}
|
|
||||||
psql -U postgres -c "ALTER USER ${ini[postgresql.homeassistant_user]} WITH PASSWORD '${ini[postgresql.homeassistant_password]}'"
|
|
||||||
|
|
||||||
cl-core-setup -n postgresql -f
|
|
||||||
|
|
||||||
/etc/init.d/postgresql-$pg_ver restart
|
|
||||||
|
Loading…
Reference in new issue