mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 13:14:21 +01:00
Almond (#807)
* Initial support for almond * Fix execution * Fix package * fix style * Use package * Try origin * Fix build * Fix build * Support multiarch * Fix readme * Remove i386 * Fix pipeline * Update version * cleanup * Fix name * test-ingress * Improve nginx * cleanup config * add panel icon * Add support for ingress * Add API access * Fix script * Fix panel icon * fix quite mode * Update run.sh * Fix auth * Update almond version * Update version * Fix lint * do not modify hostname * Update version * Address comments * Fix nginx * cleanup * working * Update version * Fix API injection * cleanup nginx config * do not set an refresh token * Update almond/data/run.sh Co-Authored-By: Paulus Schoutsen <balloob@gmail.com> * Fix command * change timehandling * debug code * debug v2 * Fix value * Debug v3 * Cleanup * Fix token valid * Fix command * Add debug * Add unzip * Fix config settings
This commit is contained in:
@@ -4,4 +4,5 @@ ignored:
|
|||||||
- DL3007
|
- DL3007
|
||||||
- DL3008
|
- DL3008
|
||||||
- DL3018
|
- DL3018
|
||||||
|
- DL4006
|
||||||
- SC2046
|
- SC2046
|
||||||
|
|||||||
50
almond/Dockerfile
Normal file
50
almond/Dockerfile
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
ARG BUILD_FROM
|
||||||
|
FROM ${BUILD_FROM}
|
||||||
|
|
||||||
|
# Install Alomond requirements
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
software-properties-common \
|
||||||
|
gnupg \
|
||||||
|
nginx \
|
||||||
|
unzip \
|
||||||
|
\
|
||||||
|
&& curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
|
||||||
|
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
|
||||||
|
&& echo "deb https://deb.nodesource.com/node_12.x buster main" > /etc/apt/sources.list.d/nodesource.list \
|
||||||
|
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
|
||||||
|
\
|
||||||
|
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
nodejs \
|
||||||
|
yarn \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
|
# Install Almond
|
||||||
|
ARG ALMOND_COMMIT
|
||||||
|
WORKDIR /opt/almond
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
git \
|
||||||
|
python-dev \
|
||||||
|
build-essential \
|
||||||
|
\
|
||||||
|
&& git clone https://github.com/stanford-oval/almond-server . \
|
||||||
|
&& git checkout ${ALMOND_COMMIT} \
|
||||||
|
&& rm -fr .git \
|
||||||
|
&& yarn \
|
||||||
|
\
|
||||||
|
&& apt-get purge -y --auto-remove \
|
||||||
|
git \
|
||||||
|
python-dev \
|
||||||
|
build-essential \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& rm -fr /root/.cache
|
||||||
|
|
||||||
|
# Base env settings
|
||||||
|
ENV LANG=en_US.utf8
|
||||||
|
ENV THINGENGINE_HOME=/data/almond-server
|
||||||
|
ENV THINGENGINE_HOST_BASED_AUTHENTICATION=local-ip
|
||||||
|
|
||||||
|
COPY data/run.sh /
|
||||||
|
COPY data/nginx.conf /etc/nginx/
|
||||||
|
|
||||||
|
CMD ["/run.sh"]
|
||||||
53
almond/README.md
Normal file
53
almond/README.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Hass.io Core Add-on: Almond
|
||||||
|
|
||||||
|
Almond For Home Servers.
|
||||||
|
|
||||||
|
![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports i386 Architecture][i386-shield]
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
The installation of this add-on is straightforward and easy to do.
|
||||||
|
|
||||||
|
1. Navigate in your Home Assistant frontend to **Hass.io** -> **Add-on Store**.
|
||||||
|
2. Find the "Almond" add-on and click it.
|
||||||
|
3. Click on the "INSTALL" button.
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
The basic thing to get the add-on running would be:
|
||||||
|
|
||||||
|
1. Start the add-on.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Example add-on configuration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Got questions?
|
||||||
|
|
||||||
|
You have several options to get them answered:
|
||||||
|
|
||||||
|
- The [Home Assistant Discord Chat Server][discord].
|
||||||
|
- The Home Assistant [Community Forum][forum].
|
||||||
|
- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit]
|
||||||
|
|
||||||
|
In case you've found an bug, please [open an issue on our GitHub][issue].
|
||||||
|
|
||||||
|
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
|
||||||
|
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
|
||||||
|
[armhf-shield]: https://img.shields.io/badge/armhf-no-red.svg
|
||||||
|
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg
|
||||||
|
[discord]: https://discord.gg/c5DvZ4e
|
||||||
|
[forum]: https://community.home-assistant.io
|
||||||
|
[i386-shield]: https://img.shields.io/badge/i386-no-red.svg
|
||||||
|
[issue]: https://github.com/home-assistant/hassio-addons/issues
|
||||||
|
[reddit]: https://reddit.com/r/homeassistant
|
||||||
|
[repository]: https://github.com/hassio-addons/repository
|
||||||
22
almond/azure-pipelines.yml
Normal file
22
almond/azure-pipelines.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# https://dev.azure.com/home-assistant
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
include:
|
||||||
|
- almond/*
|
||||||
|
pr: none
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- name: versionBuilder
|
||||||
|
value: '2.0'
|
||||||
|
- group: docker
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- template: /.azure/azp-template-addon.yml
|
||||||
|
parameters:
|
||||||
|
addon: 'almond'
|
||||||
|
arch: '--amd64 --armv7 --aarch64'
|
||||||
10
almond/build.json
Normal file
10
almond/build.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"build_from": {
|
||||||
|
"amd64": "homeassistant/amd64-base-debian:buster",
|
||||||
|
"armv7": "homeassistant/armv7-base-debian:buster",
|
||||||
|
"aarch64": "homeassistant/aarch64-base-debian:buster"
|
||||||
|
},
|
||||||
|
"args": {
|
||||||
|
"ALMOND_COMMIT": "87d37637c8bcaea8a86d2e1eba039184d4434049"
|
||||||
|
}
|
||||||
|
}
|
||||||
20
almond/config.json
Normal file
20
almond/config.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "Almond",
|
||||||
|
"version": "0.3",
|
||||||
|
"slug": "almond",
|
||||||
|
"description": "The home server version of Almond",
|
||||||
|
"url": "https://home-assistant.io/addons/almond/",
|
||||||
|
"arch": ["armv7", "aarch64", "amd64"],
|
||||||
|
"startup": "system",
|
||||||
|
"boot": "auto",
|
||||||
|
"discovery": ["almond"],
|
||||||
|
"ingress": true,
|
||||||
|
"panel_icon": "mdi:comment-eye-outline",
|
||||||
|
"homeassistant": "0.102.0b0",
|
||||||
|
"homeassistant_api": true,
|
||||||
|
"options": {
|
||||||
|
},
|
||||||
|
"schema": {
|
||||||
|
},
|
||||||
|
"image": "homeassistant/{arch}-addon-almond"
|
||||||
|
}
|
||||||
59
almond/data/nginx.conf
Normal file
59
almond/data/nginx.conf
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
worker_processes 1;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
error_log /dev/stdout info;
|
||||||
|
daemon off;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
proxy_read_timeout 1200;
|
||||||
|
gzip on;
|
||||||
|
gzip_disable "msie6";
|
||||||
|
|
||||||
|
upstream backend {
|
||||||
|
ip_hash;
|
||||||
|
server 127.0.0.1:3000;
|
||||||
|
}
|
||||||
|
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
|
# API & Ingress
|
||||||
|
server {
|
||||||
|
listen 3001 default_server;
|
||||||
|
listen 8099 default_server;
|
||||||
|
listen [::]:3001 default_server;
|
||||||
|
listen [::]:8099 default_server;
|
||||||
|
|
||||||
|
allow 172.30.32.1;
|
||||||
|
allow 172.30.32.2;
|
||||||
|
deny all;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
access_log /dev/stdout combined;
|
||||||
|
|
||||||
|
client_max_body_size 4G;
|
||||||
|
keepalive_timeout 5;
|
||||||
|
|
||||||
|
root /dev/null;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_pass http://backend;
|
||||||
|
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
proxy_set_header Host "127.0.0.1:3000";
|
||||||
|
proxy_set_header Origin "http://127.0.0.1:3000";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
almond/data/run.sh
Executable file
63
almond/data/run.sh
Executable file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/env bashio
|
||||||
|
WAIT_PIDS=()
|
||||||
|
TOKEN_VALID="$(python3 -c "import time; print((time.time() + 60 * 60 * 24 * 365 * 5) * 1000)")"
|
||||||
|
|
||||||
|
ha_config=$(\
|
||||||
|
bashio::var.json \
|
||||||
|
host "$(hostname)" \
|
||||||
|
port "3001" \
|
||||||
|
)
|
||||||
|
|
||||||
|
almond_config=$(\
|
||||||
|
bashio::var.json \
|
||||||
|
kind "io.home-assistant" \
|
||||||
|
hassUrl "http://hassio/homeassistant" \
|
||||||
|
accessToken "${HASSIO_TOKEN}" \
|
||||||
|
refreshToken "" \
|
||||||
|
accessTokenExpires "^${TOKEN_VALID}" \
|
||||||
|
)
|
||||||
|
|
||||||
|
# HA Discovery
|
||||||
|
if bashio::discovery "almond" "${ha_config}" > /dev/null; then
|
||||||
|
bashio::log.info "Successfully send discovery information to Home Assistant."
|
||||||
|
else
|
||||||
|
bashio::log.error "Discovery message to Home Assistant failed!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ingress handling
|
||||||
|
# shellcheck disable=SC2155
|
||||||
|
export THINGENGINE_BASE_URL=$(bashio::addon.ingress_entry)
|
||||||
|
|
||||||
|
# Setup nginx
|
||||||
|
nginx -c /etc/nginx/nginx.conf &
|
||||||
|
WAIT_PIDS+=($!)
|
||||||
|
|
||||||
|
# Skip Auth handling
|
||||||
|
if ! bashio::fs.file_exists "${THINGENGINE_HOME}/prefs.db"; then
|
||||||
|
mkdir -p "${THINGENGINE_HOME}"
|
||||||
|
echo '{"server-login":{"password":"x","salt":"x","sqliteKeySalt":"x"}}' > "${THINGENGINE_HOME}/prefs.db"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Almond
|
||||||
|
yarn start &
|
||||||
|
WAIT_PIDS+=($!)
|
||||||
|
|
||||||
|
# Insert HA connection settings
|
||||||
|
bashio::net.wait_for 3000
|
||||||
|
if curl -f -s -X POST -H "Content-Type: application/json" -d "${almond_config}" http://127.0.0.1:3000/api/devices/create; then
|
||||||
|
bashio::log.info "Successfully register local Home Assistant on Almond"
|
||||||
|
else
|
||||||
|
bashio::log.error "Almond registration of local Home Assistant fails!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Register stop
|
||||||
|
function stop_addon() {
|
||||||
|
echo "Kill Processes..."
|
||||||
|
kill -15 "${WAIT_PIDS[@]}"
|
||||||
|
wait "${WAIT_PIDS[@]}"
|
||||||
|
echo "Done."
|
||||||
|
}
|
||||||
|
trap "stop_addon" SIGTERM SIGHUP
|
||||||
|
|
||||||
|
# Wait until all is done
|
||||||
|
wait "${WAIT_PIDS[@]}"
|
||||||
BIN
almond/logo.png
Normal file
BIN
almond/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Reference in New Issue
Block a user