🔨 Rebranding to TasmoAdmin

This commit is contained in:
Franck Nijhof 2018-06-13 20:17:07 +02:00 committed by Franck Nijhof
parent df688cbae2
commit 70ca14ad7c
29 changed files with 116 additions and 151 deletions

77
tasmoadmin/.README.j2 Normal file
View file

@ -0,0 +1,77 @@
# Community Hass.io Add-ons: TasmoAdmin
[![Release][release-shield]][release] ![Project Stage][project-stage-shield] ![Project Maintenance][maintenance-shield]
[![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum]
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
Centrally manage all your Sonoff-Tasmota devices.
## About
TasmoAdmin (formerly known as SonWEB) is an administrative web interface to
manage all your Sonoff-Tasmota flashed devices centrally.
Some of its features:
- Scans your networks and adds your devices automatically
- See the status off all your devices quick and easy
- Configure all your devices from a single place
- Send out firmware updates over the air to one or more your devices at once
- Can automatically download the latest firmware for you
[Click here for the full documentation][docs]
![TasmoAdmin screenshot][screenshot]
{% if channel == "edge" %}
## WARNING! THIS IS AN EDGE VERSION!
This Hass.io Add-ons repository contains edge builds of add-ons. Edge builds
add-ons are based upon the latest development version.
- They may not work at all.
- They might stop working at any time.
- They could have a negative impact on your system.
This repository was created for:
- Anybody willing to test.
- Anybody interested in trying out upcoming add-ons or add-on features.
- Developers.
If you are more interested in stable releases of our add-ons:
<https://github.com/hassio-addons/repository>
{% endif %}
{% if channel == "beta" %}
## WARNING! THIS IS A BETA VERSION!
This Hass.io Add-ons repository contains beta releases of add-ons.
- They might stop working at any time.
- They could have a negative impact on your system.
This repository was created for:
- Anybody willing to test.
- Anybody interested in trying out upcoming add-ons or add-on features.
If you are more interested in stable releases of our add-ons:
<https://github.com/hassio-addons/repository>
{% endif %}
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg
[buymeacoffee]: https://www.buymeacoffee.com/frenck
[discord-shield]: https://img.shields.io/discord/330944238910963714.svg
[discord]: https://discord.gg/c5DvZ4e
[docs]: {{ repo }}/blob/{{ version }}/README.md
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg
[forum]: https://community.home-assistant.io/t/community-hass-io-add-on-tasmoadmin/54155?u=frenck
[maintenance-shield]: https://img.shields.io/maintenance/yes/2018.svg
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
[release-shield]: https://img.shields.io/badge/version-{{ version }}-blue.svg
[release]: {{ repo }}/tree/{{ version }}
[screenshot]: https://github.com/hassio-addons/addon-tasmoadmin/raw/master/images/screenshot.png

58
tasmoadmin/Dockerfile Executable file
View file

@ -0,0 +1,58 @@
ARG BUILD_FROM=hassioaddons/base-amd64:1.4.1
# hadolint ignore=DL3006
FROM ${BUILD_FROM}
# Setup base
RUN \
apk add --no-cache \
nginx=1.12.2-r3 \
patch=2.7.5-r2 \
php7-curl=7.1.17-r0 \
php7-fpm=7.1.17-r0 \
php7-json=7.1.17-r0 \
php7-opcache=7.1.17-r0 \
php7-session=7.1.17-r0 \
php7-zip=7.1.17-r0 \
php7=7.1.17-r0 \
\
&& apk add --no-cache --virtual .build-dependencies \
git=2.15.0-r1 \
\
&& git clone --branch master --single-branch \
https://github.com/reloxx13/TasmoAdmin.git /var/www/tasmoadmin \
&& git -C /var/www/tasmoadmin checkout 74704ba33f7b4df0d5fd75c55253356edbb65029 \
\
&& apk del --purge .build-dependencies \
\
&& rm -f -r /var/www/tasmoadmin/.git \
&& find /var/www/tasmoadmin -type f -name ".htaccess" -depth -exec rm -f {} \; \
&& find /var/www/tasmoadmin -type f -name "*.md" -depth -exec rm -f {} \; \
&& find /var/www/tasmoadmin -type f -name ".gitignore" -depth -exec rm -f {} \; \
&& find /var/www/tasmoadmin -type f -name ".empty" -depth -exec rm -f {} \;
# Copy root filesystem
COPY rootfs /
# Build arugments
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_REF
ARG BUILD_VERSION
# Labels
LABEL \
io.hass.name="TasmoAdmin" \
io.hass.description="Centrally manage all your Sonoff-Tasmota devices" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="Franck Nijhof <frenck@addons.community>" \
org.label-schema.description="Centrally manage all your Sonoff-Tasmota devices" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="TasmoAdmin" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://community.home-assistant.io/t/community-hass-io-add-on-tasmoadmin/54155?u=frenck" \
org.label-schema.usage="https://github.com/hassio-addons/addon-tasmoadmin/tree/master/README.md" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-url="https://github.com/hassio-addons/addon-tasmoadmin" \
org.label-schema.vendor="Community Hass.io Addons"

10
tasmoadmin/build.json Executable file
View file

@ -0,0 +1,10 @@
{
"squash": false,
"build_from": {
"aarch64": "hassioaddons/base-aarch64:1.4.1",
"amd64": "hassioaddons/base-amd64:1.4.1",
"armhf": "hassioaddons/base-armhf:1.4.1",
"i386": "hassioaddons/base-i386:1.4.1"
},
"args": {}
}

40
tasmoadmin/config.json Executable file
View file

@ -0,0 +1,40 @@
{
"name": "TasmoAdmin",
"version": "dev",
"slug": "sonweb",
"description": "Centrally manage all your Sonoff-Tasmota devices",
"url": "https://community.home-assistant.io/t/community-hass-io-add-on-tasmoadmin/54155?u=frenck",
"webui": "[PROTO:ssl]://[HOST]:[PORT:9541]",
"startup": "system",
"arch": [
"aarch64",
"amd64",
"armhf",
"i386"
],
"boot": "auto",
"hassio_api": true,
"map": [
"ssl"
],
"ports": {
"9541/tcp": 9541
},
"options": {
"log_level": "info",
"ssl": false,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"ipv6": false
},
"schema": {
"log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)",
"ssl": "bool",
"certfile": "str",
"keyfile": "str",
"ipv6": "bool"
},
"environment": {
"LOG_FORMAT": "{LEVEL}: {MESSAGE}"
}
}

BIN
tasmoadmin/icon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
tasmoadmin/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View file

@ -0,0 +1,26 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: TasmoAdmin
# This files check if all user configuration requirements are met
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# Check SSL requirements, if enabled
if hass.config.true 'ssl'; then
if ! hass.config.has_value 'certfile'; then
hass.die 'SSL is enabled, but no certfile was specified'
fi
if ! hass.config.has_value 'keyfile'; then
hass.die 'SSL is enabled, but no keyfile was specified'
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'certfile')"; then
hass.die 'The configured certfile is not found'
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'keyfile')"; then
hass.die 'The configured keyfile is not found'
fi
fi

View file

@ -0,0 +1,25 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: TasmoAdmin
# Configures NGINX for use with TasmoAdmin
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
declare certfile
declare keyfile
if hass.config.true 'ssl'; then
rm /etc/nginx/nginx.conf
mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf
certfile=$(hass.config.get 'certfile')
keyfile=$(hass.config.get 'keyfile')
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
fi
if ! hass.config.true 'ipv6'; then
sed -i '/listen \[::\].*/ d' /etc/nginx/nginx.conf
fi

View file

@ -0,0 +1,19 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: TasmoAdmin
# Migrates data from sonweb to TasmoAdmin
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
if hass.directory_exists "/data/sonweb"; then
hass.log.inf 'Migrating data from sonweb to tasmoadmin...'
# Rename data folder
mv /data/sonweb /data/tasmoadmin
# Ensure file permissions
chown -R nginx:nginx /data/tasmoadmin
find /data/tasmoadmin -not -perm 0644 -type f -exec chmod 0644 {} \;
find /data/tasmoadmin -not -perm 0755 -type d -exec chmod 0755 {} \;
fi

View file

@ -0,0 +1,23 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: TasmoAdmin
# Ensures data is store in a persistent location
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
if ! hass.directory_exists "/data/tasmoadmin"; then
hass.log.debug 'Data directory not initialized, doing that now...'
# Setup structure
cp -R /var/www/tasmoadmin/data /data/tasmoadmin
# Ensure file permissions
chown -R nginx:nginx /data/tasmoadmin
find /data/tasmoadmin -not -perm 0644 -type f -exec chmod 0644 {} \;
find /data/tasmoadmin -not -perm 0755 -type d -exec chmod 0755 {} \;
fi
hass.log.debug 'Symlinking data directory to persistent storage location...'
rm -f -r /var/www/tasmoadmin/data
ln -s /data/tasmoadmin /var/www/tasmoadmin/data

View file

@ -0,0 +1,2 @@
/var/www/tasmoadmin true nginx 0644 0755
/data/tasmoadmin true nginx 0644 0755

View file

@ -0,0 +1,67 @@
worker_processes 1;
pid /var/run/nginx.pid;
user nginx nginx;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
server_name hassio.local;
listen 9541 default_server ssl;
listen [::]:9541 default_server ssl;
root /var/www/tasmoadmin;
index index.php;
ssl_certificate /ssl/%%certfile%%;
ssl_certificate_key /ssl/%%keyfile%%;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA;
ssl_ecdh_curve secp384r1;
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
location /data/ {
deny all;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_read_timeout 900;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^(.*)\.(css|js|gif||jpe?g|png|json|cache\.json)$ {
}
location / {
rewrite ^/login$ /login.php last;
rewrite ^/logout$ /login.php?logout=logout last;
rewrite ^/doAjaxAll$ /index.php?doAjaxAll=doAjaxAll last;
rewrite ^/doAjax$ /index.php?doAjax=doAjax last;
rewrite "/([a-z]{2})/" /index.php?lang=$1 last;
rewrite ^/([a-zA-Z_]+)/([a-zA-Z_]+)/([0-9_]+)/?$ /index.php?page=$1&action=$2&device_id=$3;
rewrite ^/([a-zA-Z_]+)/(force)/?$ /index.php?page=$1&force=1;
rewrite ^/([a-zA-Z_]+)/([a-zA-Z_]+)/?$ /index.php?page=$1&action=$2;
rewrite ^/([a-zA-Z_]+)/([0-9]+)/?$ /index.php?page=$1&device_id=$2;
rewrite ^/([a-zA-Z_]+)/?$ /index.php?page=$1;
}
}
}

View file

@ -0,0 +1,54 @@
worker_processes 1;
pid /var/run/nginx.pid;
user nginx nginx;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
server_name hassio.local;
listen 9541 default_server;
listen [::]:9541 default_server;
root /var/www/tasmoadmin/;
index index.php;
location /data/firmwares {
}
location /data/ {
deny all;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_read_timeout 900;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^(.*)\.(css|js|gif||jpe?g|png|json|cache\.json)$ {
}
location / {
rewrite ^/login$ /login.php last;
rewrite ^/logout$ /login.php?logout=logout last;
rewrite ^/doAjaxAll$ /index.php?doAjaxAll=doAjaxAll last;
rewrite ^/doAjax$ /index.php?doAjax=doAjax last;
rewrite "/([a-z]{2})/" /index.php?lang=$1 last;
rewrite ^/([a-zA-Z_]+)/([a-zA-Z_]+)/([0-9_]+)/?$ /index.php?page=$1&action=$2&device_id=$3;
rewrite ^/([a-zA-Z_]+)/(force)/?$ /index.php?page=$1&force=1;
rewrite ^/([a-zA-Z_]+)/([a-zA-Z_]+)/?$ /index.php?page=$1&action=$2;
rewrite ^/([a-zA-Z_]+)/([0-9]+)/?$ /index.php?page=$1&device_id=$2;
rewrite ^/([a-zA-Z_]+)/?$ /index.php?page=$1;
}
}
}

View file

@ -0,0 +1,2 @@
/data/tasmoadmin/*
/var/www/tasmoadmin/data/*

View file

@ -0,0 +1,9 @@
[general]
max_execution_time = 900
opcache.enable=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4096
opcache.memory_consumption=32
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.blacklist_filename=/etc/php7/blacklist.txt

View file

@ -0,0 +1,11 @@
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9001
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_requests = 1024
clear_env = yes

View file

@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Community Hass.io Add-ons: TasmoAdmin
# Take down the S6 supervision tree when Nginx fails
# ==============================================================================
if -n { s6-test $# -ne 0 }
if -n { s6-test ${1} -eq 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -0,0 +1,12 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: TasmoAdmin
# Runs the Nginx daemon
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# Wait for PHP-FPM to become available
s6-svwait -u -t 5000 /var/run/s6/services/php-fpm
exec nginx -g "daemon off;"

View file

@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Community Hass.io Add-ons: TasmoAdmin
# Take down the S6 supervision tree when PHP FPM fails
# ==============================================================================
if -n { s6-test $# -ne 0 }
if -n { s6-test ${1} -eq 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -0,0 +1,9 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: TasmoAdmin
# Runs the PHP-FPM daemon
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
exec php-fpm7 --nodaemonize

View file

@ -0,0 +1 @@
# Disables updater