diff --git a/profiles/templates/homeassistant/.calculate_directory b/profiles/templates/homeassistant/.calculate_directory new file mode 100644 index 0000000..61a1d74 --- /dev/null +++ b/profiles/templates/homeassistant/.calculate_directory @@ -0,0 +1 @@ +# Calculate os_linux_shortname==homeassistant cl_name==calculate-core append=skip diff --git a/profiles/templates/homeassistant/homeassistant/.calculate_directory b/profiles/templates/homeassistant/homeassistant/.calculate_directory new file mode 100644 index 0000000..ae03782 --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/.calculate_directory @@ -0,0 +1 @@ +# Calculate env=install ac_install_merge==on mergepkg(www-servers/nginx)!= append=skip diff --git a/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.group b/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.group new file mode 100644 index 0000000..622a6ea --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.group @@ -0,0 +1,2 @@ +# Calculate append=after path=/etc name=#-cut(2,.)-# grep(/etc/#-cut(2,.)-#,#-cut(1,.)-#)== protected +homeassistant:x:999: diff --git a/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.passwd b/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.passwd new file mode 100644 index 0000000..e7679b0 --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.passwd @@ -0,0 +1,2 @@ +# Calculate append=after path=/etc name=#-cut(2,.)-# grep(/etc/#-cut(2,.)-#,#-cut(1,.)-#)== protected +homeassistant:x:999:999::/var/calculate/www/homeassistant:/bin/bash diff --git a/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.shadow b/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.shadow new file mode 100644 index 0000000..aa7a872 --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/0-etc.homeassistant.shadow @@ -0,0 +1,2 @@ +# Calculate append=after path=/etc name=#-cut(2,.)-# grep(/etc/#-cut(2,.)-#,#-cut(1,.)-#)== protected +homeassistant:!:19443:::::: diff --git a/profiles/templates/homeassistant/homeassistant/ini.env b/profiles/templates/homeassistant/homeassistant/ini.env new file mode 100644 index 0000000..29ca4ce --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/ini.env @@ -0,0 +1,4 @@ +# Calculate format=samba path=/var/calculate chmod=600 chown=homeassistant:homeassistant comment=# grep(/var/calculate/ini.env,homeassistant)== protected +[homeassistant] +protocol = http +domain = home.example.org diff --git a/profiles/templates/homeassistant/homeassistant/init.homeassistant b/profiles/templates/homeassistant/homeassistant/init.homeassistant new file mode 100644 index 0000000..aa9c7fd --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/init.homeassistant @@ -0,0 +1,36 @@ +# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=# exists(/var/calculate/www/homeassistant/.venv)!= +#!/sbin/openrc-run + +description="Open-source home automation platform" + +user="homeassistant:homeassistant" + +stdoutlog="/var/log/homeassistant/stdout.log" +serverlog="/var/log/homeassistant/server.log" +warningslog="/var/log/homeassistant/warnings.log" +retry="20" + +command=/var/calculate/www/homeassistant/.venv/bin/hass +directory=/var/calculate/www/homeassistant + +start_stop_daemon_args="--user $user --stdout $stdoutlog --stderr $serverlog --wait 10" + +command_args=" + --log-file $warningslog + --log-rotate-days 9 + ${HASS_OPTS} +" + +command_background=yes +pidfile=/run/homeassistant.pid + +depend() { + need net postgresql +# need net nginx postgresql +} + +start_pre() { + checkpath --file --owner $user --mode 0644 $stdoutlog + checkpath --file --owner $user --mode 0644 $serverlog + checkpath --file --owner $user --mode 0644 $warningslog +} diff --git a/profiles/templates/homeassistant/homeassistant/link.cl-setup b/profiles/templates/homeassistant/homeassistant/link.cl-setup new file mode 100644 index 0000000..b41a55e --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/link.cl-setup @@ -0,0 +1 @@ +# Calculate path=/usr/sbin name=#-cut(1,.)-# link=/var/db/repos/container/scripts/homeassistant/setup.sh symbolic protected diff --git a/profiles/templates/homeassistant/homeassistant/log/.calculate_directory b/profiles/templates/homeassistant/homeassistant/log/.calculate_directory new file mode 100644 index 0000000..c4ea7e3 --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/log/.calculate_directory @@ -0,0 +1 @@ +# Calculate path=/var/log name=homeassistant chown=homeassistant:homeassistant diff --git a/profiles/templates/homeassistant/homeassistant/runlevel.homeassistant b/profiles/templates/homeassistant/homeassistant/runlevel.homeassistant new file mode 100644 index 0000000..fafbec5 --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/runlevel.homeassistant @@ -0,0 +1 @@ +# Calculate path=/etc/runlevels/default name=#-cut(1,.)-# link=/etc/init.d/#-cut(1,.)-# protected symbolic exists(/var/calculate/www/homeassistant/.venv)!= diff --git a/profiles/templates/homeassistant/homeassistant/www/.calculate_directory b/profiles/templates/homeassistant/homeassistant/www/.calculate_directory new file mode 100644 index 0000000..814ccaf --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/www/.calculate_directory @@ -0,0 +1 @@ +# Calculate path=/var/calculate diff --git a/profiles/templates/homeassistant/homeassistant/www/homeassistant/.calculate_directory b/profiles/templates/homeassistant/homeassistant/www/homeassistant/.calculate_directory new file mode 100644 index 0000000..a6ec39b --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/www/homeassistant/.calculate_directory @@ -0,0 +1 @@ +# Calculate chmod=750 chown=homeassistant:nginx diff --git a/profiles/templates/homeassistant/homeassistant/x-ini.env b/profiles/templates/homeassistant/homeassistant/x-ini.env new file mode 100644 index 0000000..d916800 --- /dev/null +++ b/profiles/templates/homeassistant/homeassistant/x-ini.env @@ -0,0 +1,10 @@ +# 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 diff --git a/profiles/templates/homeassistant/nginx/.calculate_directory b/profiles/templates/homeassistant/nginx/.calculate_directory new file mode 100644 index 0000000..ae03782 --- /dev/null +++ b/profiles/templates/homeassistant/nginx/.calculate_directory @@ -0,0 +1 @@ +# Calculate env=install ac_install_merge==on mergepkg(www-servers/nginx)!= append=skip diff --git a/profiles/templates/homeassistant/nginx/homeassistant.conf b/profiles/templates/homeassistant/nginx/homeassistant.conf new file mode 100644 index 0000000..99e30d5 --- /dev/null +++ b/profiles/templates/homeassistant/nginx/homeassistant.conf @@ -0,0 +1,50 @@ +# Calculate path=/etc/nginx/sites-enabled exists(/etc/nginx/sites-enabled/#-cut()-#)== comment=# +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +server { + # These shouldn't need to be changed + listen 80 default_server; + #return 301 https://$host$request_uri; +} + +server { + # Update this line to be your domain + #server_name home.example.org; + + access_log /var/log/nginx/homeassistant.access_log main; + error_log /var/log/nginx/homeassistant.error_log info; + + # Ensure these lines point to your SSL certificate and key + ssl_certificate /etc/nginx/ssl/homeassistant/fullchain.pem; + ssl_certificate_key /etc/nginx/ssl/homeassistant/privkey.pem; + + # Ensure this line points to your dhparams file +# ssl_dhparam /etc/nginx/ssl/dhparams.pem; + + + # These shouldn't need to be changed +# listen [::]:443 ssl default_server ipv6only=off; # if your nginx version is >= 1.9.5 you can also add the "http2" flag here + listen 443 ssl default_server; # if your nginx version is >= 1.9.5 you can also add the "http2" flag here + add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; + + ssl_protocols TLSv1.2; + ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + + proxy_buffering off; + + location / { + proxy_pass http://127.0.0.1:8123; + proxy_set_header Host localhost; + #proxy_set_header Host $host; + proxy_redirect http:// https://; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + } +} diff --git a/profiles/templates/homeassistant/nginx/link.homeassistant b/profiles/templates/homeassistant/nginx/link.homeassistant new file mode 100644 index 0000000..fbc4222 --- /dev/null +++ b/profiles/templates/homeassistant/nginx/link.homeassistant @@ -0,0 +1 @@ +# Calculate path=/etc/nginx/ssl name=#-cut(1,.)-# link=/var/calculate/ssl symbolic protected diff --git a/profiles/templates/homeassistant/nginx/ssl/.calculate_directory b/profiles/templates/homeassistant/nginx/ssl/.calculate_directory new file mode 100644 index 0000000..814ccaf --- /dev/null +++ b/profiles/templates/homeassistant/nginx/ssl/.calculate_directory @@ -0,0 +1 @@ +# Calculate path=/var/calculate diff --git a/profiles/templates/homeassistant/postgresql/.calculate_directory b/profiles/templates/homeassistant/postgresql/.calculate_directory new file mode 100644 index 0000000..0e3fbac --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/.calculate_directory @@ -0,0 +1 @@ +# Calculate env=install ac_install_merge==on mergepkg(dev-db/postgresql)!= append=skip diff --git a/profiles/templates/homeassistant/postgresql/0-get_ver b/profiles/templates/homeassistant/postgresql/0-get_ver new file mode 100644 index 0000000..520431b --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/0-get_ver @@ -0,0 +1,5 @@ +# Calculate run=/bin/bash + +ver=$(ls -d /var/db/pkg/dev-db/postgresql-*) +ver=${ver#*postgresql-} +echo ${ver%%.*} > /tmp/pgsqlver diff --git a/profiles/templates/homeassistant/postgresql/database/.calculate_directory b/profiles/templates/homeassistant/postgresql/database/.calculate_directory new file mode 100644 index 0000000..16336cf --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/database/.calculate_directory @@ -0,0 +1 @@ +# Calculate path=/var/calculate name=postgresql chmod=700 chown=postgres:postgres diff --git a/profiles/templates/homeassistant/postgresql/etc/.calculate_directory b/profiles/templates/homeassistant/postgresql/etc/.calculate_directory new file mode 100644 index 0000000..f733fc4 --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/etc/.calculate_directory @@ -0,0 +1 @@ +# Calculate path=/etc name=postgresql-#-load(char,/tmp/pgsqlver)-# diff --git a/profiles/templates/homeassistant/postgresql/etc/pg_hba.conf b/profiles/templates/homeassistant/postgresql/etc/pg_hba.conf new file mode 100644 index 0000000..ab6594f --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/etc/pg_hba.conf @@ -0,0 +1,10 @@ +# Calculate chmod=600 comment=# chown=postgres:postgres + +# TYPE DATABASE USER ADDRESS METHOD + +# "local" is for Unix domain socket connections only +local all all password +# IPv4 local connections: +host all all 127.0.0.1/32 password +# IPv6 local connections: +host all all ::1/128 password diff --git a/profiles/templates/homeassistant/postgresql/etc/pg_ident.conf b/profiles/templates/homeassistant/postgresql/etc/pg_ident.conf new file mode 100644 index 0000000..4559188 --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/etc/pg_ident.conf @@ -0,0 +1 @@ +# Calculate chmod=600 comment=# chown=postgres:postgres diff --git a/profiles/templates/homeassistant/postgresql/etc/postgresql.conf b/profiles/templates/homeassistant/postgresql/etc/postgresql.conf new file mode 100644 index 0000000..ed064ba --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/etc/postgresql.conf @@ -0,0 +1,22 @@ +# Calculate chmod=600 comment=# chown=postgres:postgres + +max_connections = 100 # (change requires restart) +shared_buffers = 128MB # min 128kB +dynamic_shared_memory_type = posix # the default is the first option +max_wal_size = 1GB +min_wal_size = 80MB +log_timezone = 'W-SU' +datestyle = 'iso, dmy' +timezone = 'W-SU' +lc_messages = '#-os_install_locale_lang-#.UTF-8' +lc_monetary = '#-os_install_locale_lang-#.UTF-8' +lc_numeric = 'C' +lc_time = '#-os_install_locale_lang-#.UTF-8' +#?os_locale_language==ru# +default_text_search_config = 'pg_catalog.russian' +#!os_locale_language# +default_text_search_config = 'pg_catalog.english' +#os_locale_language# +plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";' + +listen_addresses = '127.0.0.1' diff --git a/profiles/templates/homeassistant/postgresql/ini.env b/profiles/templates/homeassistant/postgresql/ini.env new file mode 100644 index 0000000..fb91a53 --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/ini.env @@ -0,0 +1,4 @@ +# Calculate format=samba path=/var/calculate grep(/var/calculate/ini.env,postgresql)== comment=# protected +[postgresql] +postgres_password = #-rnd(pas,12)-# +homeassistant_password = #-rnd(pas,12)-# diff --git a/profiles/templates/homeassistant/postgresql/link.database b/profiles/templates/homeassistant/postgresql/link.database new file mode 100644 index 0000000..6c5199d --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/link.database @@ -0,0 +1 @@ +# Calculate path=/var/lib name=postgresql link=/var/calculate/postgresql symbolic protected diff --git a/profiles/templates/homeassistant/postgresql/pgpass b/profiles/templates/homeassistant/postgresql/pgpass new file mode 100644 index 0000000..fe2c9d8 --- /dev/null +++ b/profiles/templates/homeassistant/postgresql/pgpass @@ -0,0 +1,3 @@ +# Calculate path=/root name=.pgpass chmod=600 comment=# protected +localhost:*:*:postgres:#-ini(postgresql.postgres_password)-# +localhost:*:*:homeassistant:#-ini(postgresql.homeassistant_password)-# diff --git a/profiles/templates/homeassistant/world b/profiles/templates/homeassistant/world new file mode 100644 index 0000000..9e9f7ed --- /dev/null +++ b/profiles/templates/homeassistant/world @@ -0,0 +1,7 @@ +# Calculate env=update ac_update_sync==on path=/var/lib/portage cl_update_world==merge||cl_update_world==rebuild format=world +app-admin/syslog-ng +app-text/tree +dev-db/postgresql +#media-video/ffmpeg +sys-process/cronie +www-servers/nginx