mirror of
https://github.com/koush/scrypted.git
synced 2026-02-03 14:13:28 +00:00
ha: addon
This commit is contained in:
2
.github/workflows/docker-HEAD.yml
vendored
2
.github/workflows/docker-HEAD.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
build:
|
||||
name: Push Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
|
||||
2
.github/workflows/docker-common.yml
vendored
2
.github/workflows/docker-common.yml
vendored
@@ -9,7 +9,7 @@ on:
|
||||
- cron: '30 8 2 * *'
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
build:
|
||||
name: Push Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
|
||||
43
.github/workflows/docker.yml
vendored
43
.github/workflows/docker.yml
vendored
@@ -13,7 +13,7 @@ on:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
build:
|
||||
name: Push Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
@@ -33,10 +33,6 @@ jobs:
|
||||
- name: Print Version
|
||||
run: echo "Version ${{ github.event.inputs.package_version || steps.package-version.outputs.current-version }}"
|
||||
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
@@ -56,14 +52,14 @@ jobs:
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image (scrypted)
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
build-args: |
|
||||
BASE=${{ matrix.BASE }}
|
||||
SCRYPTED_INSTALL_VERSION=${{ github.event.inputs.package_version }}
|
||||
context: docker/
|
||||
file: docker/Dockerfile${{ matrix.SUPERVISOR }}
|
||||
context: install/docker/
|
||||
file: install/docker/Dockerfile${{ matrix.SUPERVISOR }}
|
||||
platforms: linux/amd64,linux/arm64,linux/armhf
|
||||
push: true
|
||||
tags: |
|
||||
@@ -84,3 +80,34 @@ jobs:
|
||||
${{ github.event.inputs.docker_tag == 'latest' && matrix.BASE == '18-bullseye-thin' && matrix.SUPERVISOR == '.s6' && 'ghcr.io/koush/scrypted:thin-s6' || '' }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
home_assistant:
|
||||
name: Push Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: get-npm-version
|
||||
id: package-version
|
||||
uses: martinbeentjes/npm-get-version-action@master
|
||||
with:
|
||||
path: server
|
||||
|
||||
- name: Print Version
|
||||
run: echo "Version ${{ github.event.inputs.package_version || steps.package-version.outputs.current-version }}"
|
||||
|
||||
- name: Build and push Home Asistant image
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ha_addon/
|
||||
file: ha_addon/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64,linux/armhf
|
||||
push: true
|
||||
tags: |
|
||||
${{ format('koush/scrypted:homeassistant-v{0}', github.event.inputs.package_version || steps.package-version.outputs.current-version) }}
|
||||
${{ github.event.inputs.docker_tag == 'latest' && 'koush/scrypted:homeassistant' || '' }}
|
||||
|
||||
${{ format('ghcr.io/koush/scrypted:homeassistant-v{0}', github.event.inputs.package_version || steps.package-version.outputs.current-version) }}
|
||||
${{ github.event.inputs.docker_tag == 'latest' && 'ghcr.io/koush/scrypted:homeassistant' || '' }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
48
ha_addon/Dockerfile
Executable file
48
ha_addon/Dockerfile
Executable file
@@ -0,0 +1,48 @@
|
||||
ARG BASHIO_VERSION=0.14.3
|
||||
ARG TEMPIO_VERSION=2021.09.0
|
||||
ARG BUILD_ARCH=debian
|
||||
FROM koush/scrypted
|
||||
|
||||
ARG BASHIO_VERSION
|
||||
ARG TEMPIO_VERSION
|
||||
ARG BUILD_ARCH
|
||||
|
||||
# Install Nginx and a set of Home Assistant add-on tools
|
||||
RUN \
|
||||
set -x \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
bash \
|
||||
jq \
|
||||
tzdata \
|
||||
curl \
|
||||
ca-certificates \
|
||||
nginx-extras\
|
||||
libnginx-mod-http-lua\
|
||||
&& mkdir -p /usr/share/man/man1 \
|
||||
\
|
||||
&& mkdir -p /etc/fix-attrs.d \
|
||||
&& mkdir -p /etc/services.d \
|
||||
\
|
||||
&& curl -L -f -s -o /usr/bin/tempio \
|
||||
"https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" \
|
||||
&& chmod a+x /usr/bin/tempio \
|
||||
\
|
||||
&& mkdir -p /usr/src/bashio \
|
||||
&& curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \
|
||||
| tar -xzf - --strip 1 -C /usr/src/bashio \
|
||||
&& mv /usr/src/bashio/lib /usr/lib/bashio \
|
||||
&& ln -s /usr/lib/bashio/bashio /usr/bin/bashio \
|
||||
\
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /usr/src/* \
|
||||
&& apt-get autoremove
|
||||
|
||||
# This file is installed by NGINX as a default but we don't need it
|
||||
RUN rm -rf /etc/nginx/sites-enabled/default
|
||||
|
||||
WORKDIR /
|
||||
|
||||
# Copy root filesystem
|
||||
COPY rootfs /
|
||||
|
||||
ENTRYPOINT ["/init"]
|
||||
51
ha_addon/config.yaml
Executable file
51
ha_addon/config.yaml
Executable file
@@ -0,0 +1,51 @@
|
||||
name: Scrypted
|
||||
version: "v0.8.0"
|
||||
slug: scrypted
|
||||
description: A home automation platform powered by node.js
|
||||
url: "https://github.com/koush/scrypted"
|
||||
arch:
|
||||
- amd64
|
||||
- aarch64
|
||||
- armv7
|
||||
init: false
|
||||
ingress: true
|
||||
ingress_port: 0
|
||||
panel_icon: mdi:memory
|
||||
hassio_api: true
|
||||
ingress_stream: true
|
||||
host_network: true
|
||||
gpio: true
|
||||
usb: true
|
||||
uart: true
|
||||
video: true
|
||||
# image: "ghcr.io/aegjoyce/{arch}-ha-addon-scrypted"
|
||||
environment:
|
||||
SCRYPTED_VOLUME: "/data/scrypted_data"
|
||||
backup_exclude:
|
||||
- '*/server/*'
|
||||
- '*/data/scrypted_data/recordings/*'
|
||||
map:
|
||||
- config
|
||||
options:
|
||||
env_vars:
|
||||
- name: SCRYPTED_ADMIN_USERNAME
|
||||
value: homeassistant
|
||||
- name: SCRYPTED_ADMIN_TOKEN
|
||||
value: homeassistant
|
||||
- name: SCRYPTED_NVR_VOLUME
|
||||
value: /data/scrypted_data/recordings
|
||||
schema:
|
||||
env_vars:
|
||||
- name: match(^SCRYPTED_([A-Z0-9_])+$)
|
||||
value: str
|
||||
devices:
|
||||
- /dev/mem
|
||||
- /dev/dri/renderD128
|
||||
- /dev/apex_0
|
||||
- /dev/apex_1
|
||||
- /dev/apex_2
|
||||
- /dev/apex_3
|
||||
- /dev/dri/card0
|
||||
- /dev/vchiq
|
||||
- /dev/video10
|
||||
- /dev/video0
|
||||
40
ha_addon/rootfs/etc/cont-init.d/nginx.sh
Executable file
40
ha_addon/rootfs/etc/cont-init.d/nginx.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/command/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Add-on: Scrypted
|
||||
# Configures NGINX
|
||||
# ==============================================================================
|
||||
declare port
|
||||
declare certfile
|
||||
declare dns_host
|
||||
declare ingress_interface
|
||||
declare ingress_port
|
||||
declare keyfile
|
||||
declare ingress_entry
|
||||
|
||||
|
||||
port=$(bashio::addon.port 71864)
|
||||
if bashio::var.has_value "${port}"; then
|
||||
bashio::config.require.ssl
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config 'keyfile')
|
||||
|
||||
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
|
||||
sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/servers/direct.conf
|
||||
sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct.conf
|
||||
|
||||
else
|
||||
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
ingress_port=$(bashio::addon.ingress_port)
|
||||
ingress_interface=$(bashio::addon.ip_address)
|
||||
ingress_entry=$(bashio::addon.ingress_entry)
|
||||
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s#%%ingress_entry%%#${ingress_entry}#g" /etc/nginx/servers/ingress.conf
|
||||
|
||||
dns_host=$(bashio::dns.host)
|
||||
sed -i "s/%%dns_host%%/${dns_host}/g" /etc/nginx/includes/resolver.conf
|
||||
96
ha_addon/rootfs/etc/nginx/includes/mime.types
Executable file
96
ha_addon/rootfs/etc/nginx/includes/mime.types
Executable file
@@ -0,0 +1,96 @@
|
||||
types {
|
||||
text/html html htm shtml;
|
||||
text/css css;
|
||||
text/xml xml;
|
||||
image/gif gif;
|
||||
image/jpeg jpeg jpg;
|
||||
application/javascript js;
|
||||
application/atom+xml atom;
|
||||
application/rss+xml rss;
|
||||
|
||||
text/mathml mml;
|
||||
text/plain txt;
|
||||
text/vnd.sun.j2me.app-descriptor jad;
|
||||
text/vnd.wap.wml wml;
|
||||
text/x-component htc;
|
||||
|
||||
image/png png;
|
||||
image/svg+xml svg svgz;
|
||||
image/tiff tif tiff;
|
||||
image/vnd.wap.wbmp wbmp;
|
||||
image/webp webp;
|
||||
image/x-icon ico;
|
||||
image/x-jng jng;
|
||||
image/x-ms-bmp bmp;
|
||||
|
||||
font/woff woff;
|
||||
font/woff2 woff2;
|
||||
|
||||
application/java-archive jar war ear;
|
||||
application/json json;
|
||||
application/mac-binhex40 hqx;
|
||||
application/msword doc;
|
||||
application/pdf pdf;
|
||||
application/postscript ps eps ai;
|
||||
application/rtf rtf;
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
application/vnd.google-earth.kml+xml kml;
|
||||
application/vnd.google-earth.kmz kmz;
|
||||
application/vnd.ms-excel xls;
|
||||
application/vnd.ms-fontobject eot;
|
||||
application/vnd.ms-powerpoint ppt;
|
||||
application/vnd.oasis.opendocument.graphics odg;
|
||||
application/vnd.oasis.opendocument.presentation odp;
|
||||
application/vnd.oasis.opendocument.spreadsheet ods;
|
||||
application/vnd.oasis.opendocument.text odt;
|
||||
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
||||
pptx;
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
xlsx;
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||
docx;
|
||||
application/vnd.wap.wmlc wmlc;
|
||||
application/x-7z-compressed 7z;
|
||||
application/x-cocoa cco;
|
||||
application/x-java-archive-diff jardiff;
|
||||
application/x-java-jnlp-file jnlp;
|
||||
application/x-makeself run;
|
||||
application/x-perl pl pm;
|
||||
application/x-pilot prc pdb;
|
||||
application/x-rar-compressed rar;
|
||||
application/x-redhat-package-manager rpm;
|
||||
application/x-sea sea;
|
||||
application/x-shockwave-flash swf;
|
||||
application/x-stuffit sit;
|
||||
application/x-tcl tcl tk;
|
||||
application/x-x509-ca-cert der pem crt;
|
||||
application/x-xpinstall xpi;
|
||||
application/xhtml+xml xhtml;
|
||||
application/xspf+xml xspf;
|
||||
application/zip zip;
|
||||
|
||||
application/octet-stream bin exe dll;
|
||||
application/octet-stream deb;
|
||||
application/octet-stream dmg;
|
||||
application/octet-stream iso img;
|
||||
application/octet-stream msi msp msm;
|
||||
|
||||
audio/midi mid midi kar;
|
||||
audio/mpeg mp3;
|
||||
audio/ogg ogg;
|
||||
audio/x-m4a m4a;
|
||||
audio/x-realaudio ra;
|
||||
|
||||
video/3gpp 3gpp 3gp;
|
||||
video/mp2t ts;
|
||||
video/mp4 mp4;
|
||||
video/mpeg mpeg mpg;
|
||||
video/quicktime mov;
|
||||
video/webm webm;
|
||||
video/x-flv flv;
|
||||
video/x-m4v m4v;
|
||||
video/x-mng mng;
|
||||
video/x-ms-asf asx asf;
|
||||
video/x-ms-wmv wmv;
|
||||
video/x-msvideo avi;
|
||||
}
|
||||
15
ha_addon/rootfs/etc/nginx/includes/proxy_params.conf
Executable file
15
ha_addon/rootfs/etc/nginx/includes/proxy_params.conf
Executable file
@@ -0,0 +1,15 @@
|
||||
proxy_http_version 1.1;
|
||||
proxy_ignore_client_abort off;
|
||||
proxy_read_timeout 86400s;
|
||||
proxy_redirect off;
|
||||
proxy_send_timeout 86400s;
|
||||
proxy_max_temp_file_size 0;
|
||||
|
||||
proxy_set_header Accept-Encoding "";
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
1
ha_addon/rootfs/etc/nginx/includes/resolver.conf
Executable file
1
ha_addon/rootfs/etc/nginx/includes/resolver.conf
Executable file
@@ -0,0 +1 @@
|
||||
resolver %%dns_host%%;
|
||||
6
ha_addon/rootfs/etc/nginx/includes/server_params.conf
Executable file
6
ha_addon/rootfs/etc/nginx/includes/server_params.conf
Executable file
@@ -0,0 +1,6 @@
|
||||
root /dev/null;
|
||||
server_name $hostname;
|
||||
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Robots-Tag none;
|
||||
9
ha_addon/rootfs/etc/nginx/includes/ssl_params.conf
Executable file
9
ha_addon/rootfs/etc/nginx/includes/ssl_params.conf
Executable file
@@ -0,0 +1,9 @@
|
||||
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;
|
||||
3
ha_addon/rootfs/etc/nginx/includes/upstream.conf
Executable file
3
ha_addon/rootfs/etc/nginx/includes/upstream.conf
Executable file
@@ -0,0 +1,3 @@
|
||||
upstream backend {
|
||||
server 127.0.0.1:11080;
|
||||
}
|
||||
83
ha_addon/rootfs/etc/nginx/lua/ha-auth.lua
Executable file
83
ha_addon/rootfs/etc/nginx/lua/ha-auth.lua
Executable file
@@ -0,0 +1,83 @@
|
||||
local http = require "resty.http"
|
||||
local auths = ngx.shared.auths
|
||||
|
||||
function authenticate()
|
||||
|
||||
--- Test Authentication header is set and with a value
|
||||
local header = ngx.req.get_headers()['Authorization']
|
||||
if header == nil or header:find(" ") == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
local divider = header:find(' ')
|
||||
if header:sub(0, divider-1) ~= 'Basic' then
|
||||
return false
|
||||
end
|
||||
|
||||
local auth = ngx.decode_base64(header:sub(divider+1))
|
||||
if auth == nil or auth:find(':') == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
divider = auth:find(':')
|
||||
local username = auth:sub(0, divider-1)
|
||||
local password = auth:sub(divider+1)
|
||||
|
||||
--- Check if authentication is cached
|
||||
if auths:get(username) == password then
|
||||
ngx.log(ngx.DEBUG, "Authenticated user against Home Assistant (cache).")
|
||||
return true
|
||||
end
|
||||
|
||||
--- HTTP request against the Supervisor API
|
||||
local httpc = http.new()
|
||||
local res, err = httpc:request_uri("http://supervisor.local.hass.io/auth", {
|
||||
method = "POST",
|
||||
body = ngx.encode_args({["username"]=username, ["password"]=password}),
|
||||
headers = {
|
||||
["Content-Type"] = "application/x-www-form-urlencoded",
|
||||
["X-Supervisor-Token"] = os.getenv("SUPERVISOR_TOKEN"),
|
||||
},
|
||||
keepalive_timeout = 60,
|
||||
keepalive_pool = 10
|
||||
})
|
||||
|
||||
--- Error during API request
|
||||
if err then
|
||||
ngx.log(ngx.WARN, "Error during Home Assistant user authentication.", err)
|
||||
return false
|
||||
end
|
||||
|
||||
--- No result? Something went wrong...
|
||||
if not res then
|
||||
ngx.log(ngx.WARN, "Error during Home Assistant user authentication.")
|
||||
return false
|
||||
end
|
||||
|
||||
--- Valid response, the username/password is valid
|
||||
if res.status == 200 then
|
||||
ngx.log(ngx.INFO, "Authenticated user against Home Assistant.")
|
||||
auths:set(username, password, 60)
|
||||
return true
|
||||
end
|
||||
|
||||
--- Whatever the response is, it is invalid
|
||||
ngx.log(ngx.WARN, "Authentication against Home Assistant failed!")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Only authenticate if its not disabled
|
||||
if not os.getenv('DISABLE_HA_AUTHENTICATION') then
|
||||
|
||||
--- Try to authenticate against HA
|
||||
local authenticated = authenticate()
|
||||
|
||||
--- If authentication failed, throw a basic auth
|
||||
if not authenticated then
|
||||
ngx.header.content_type = 'text/plain'
|
||||
ngx.header.www_authenticate = 'Basic realm="Home Assistant"'
|
||||
ngx.status = ngx.HTTP_UNAUTHORIZED
|
||||
ngx.say('401 Access Denied')
|
||||
ngx.exit(ngx.HTTP_UNAUTHORIZED)
|
||||
end
|
||||
end
|
||||
1
ha_addon/rootfs/etc/nginx/modules/ndk_http.conf
Executable file
1
ha_addon/rootfs/etc/nginx/modules/ndk_http.conf
Executable file
@@ -0,0 +1 @@
|
||||
load_module "/usr/lib/nginx/modules/ndk_http_module.so";
|
||||
1
ha_addon/rootfs/etc/nginx/modules/ngx_http_lua.conf
Executable file
1
ha_addon/rootfs/etc/nginx/modules/ngx_http_lua.conf
Executable file
@@ -0,0 +1 @@
|
||||
load_module "/usr/lib/nginx/modules/ngx_http_lua_module.so";
|
||||
63
ha_addon/rootfs/etc/nginx/nginx.conf
Executable file
63
ha_addon/rootfs/etc/nginx/nginx.conf
Executable file
@@ -0,0 +1,63 @@
|
||||
# Run nginx in foreground.
|
||||
daemon off;
|
||||
|
||||
# This is run inside Docker.
|
||||
user root;
|
||||
|
||||
# Pid storage location.
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
# Set number of worker processes.
|
||||
worker_processes 1;
|
||||
|
||||
# Enables the use of JIT for regular expressions to speed-up their processing.
|
||||
pcre_jit on;
|
||||
|
||||
# Write error log to the add-on log.
|
||||
error_log /proc/1/fd/1 error;
|
||||
#error_log /proc/1/fd/1 debug; # Debug logs
|
||||
|
||||
# Load allowed environment vars
|
||||
env SUPERVISOR_TOKEN;
|
||||
env DISABLE_HA_AUTHENTICATION;
|
||||
|
||||
# Load dynamic modules.
|
||||
include /etc/nginx/modules/*.conf;
|
||||
|
||||
# Max num of simultaneous connections by a worker process.
|
||||
events {
|
||||
worker_connections 512;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/includes/mime.types;
|
||||
|
||||
log_format homeassistant '[$time_local] $status $request';
|
||||
|
||||
access_log /proc/1/fd/1 homeassistant;
|
||||
client_max_body_size 4G;
|
||||
default_type application/octet-stream;
|
||||
gzip on;
|
||||
keepalive_timeout 65;
|
||||
lua_shared_dict auths 16k;
|
||||
sendfile on;
|
||||
server_tokens off;
|
||||
tcp_nodelay on;
|
||||
tcp_nopush on;
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
# https://stackoverflow.com/questions/21230918/nginx-scheme-variable-behind-load-balancer/21911864#21911864
|
||||
map $http_x_forwarded_proto $real_scheme {
|
||||
default $http_x_forwarded_proto;
|
||||
'' $scheme;
|
||||
}
|
||||
|
||||
include /etc/nginx/includes/resolver.conf;
|
||||
include /etc/nginx/includes/upstream.conf;
|
||||
|
||||
include /etc/nginx/servers/*.conf;
|
||||
}
|
||||
15
ha_addon/rootfs/etc/nginx/servers/direct-ssl.disabled
Executable file
15
ha_addon/rootfs/etc/nginx/servers/direct-ssl.disabled
Executable file
@@ -0,0 +1,15 @@
|
||||
server {
|
||||
listen 71864 default_server ssl http2;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/ssl_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
ssl_certificate /ssl/%%certfile%%;
|
||||
ssl_certificate_key /ssl/%%keyfile%%;
|
||||
|
||||
location / {
|
||||
access_by_lua_file /etc/nginx/lua/ha-auth.lua;
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
||||
11
ha_addon/rootfs/etc/nginx/servers/direct.disabled
Executable file
11
ha_addon/rootfs/etc/nginx/servers/direct.disabled
Executable file
@@ -0,0 +1,11 @@
|
||||
server {
|
||||
listen 71864 default_server;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
location / {
|
||||
access_by_lua_file /etc/nginx/lua/ha-auth.lua;
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
||||
31
ha_addon/rootfs/etc/nginx/servers/ingress.conf
Executable file
31
ha_addon/rootfs/etc/nginx/servers/ingress.conf
Executable file
@@ -0,0 +1,31 @@
|
||||
map $http_upgrade $upgradevalue {
|
||||
websocket websocket;
|
||||
default '';
|
||||
}
|
||||
map $http_upgrade $connectionvalue {
|
||||
websocket Upgrade;
|
||||
default '';
|
||||
}
|
||||
|
||||
server {
|
||||
listen %%interface%%:%%port%% default_server;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
# This is a Home Assistant requirement for Ingress
|
||||
allow 172.30.32.2;
|
||||
deny all;
|
||||
|
||||
location / {
|
||||
proxy_pass http://backend/;
|
||||
proxy_redirect ~^/(.+)$ $real_scheme://$http_host%%ingress_entry%%/$1;
|
||||
proxy_set_header Authorization "Bearer %%authorization_header%%";
|
||||
proxy_pass_header Authorization;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_set_header Upgrade $upgradevalue;
|
||||
proxy_set_header Connection $connectionvalue;
|
||||
}
|
||||
}
|
||||
3
ha_addon/rootfs/etc/options.json
Executable file
3
ha_addon/rootfs/etc/options.json
Executable file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"portOverride": 10444
|
||||
}
|
||||
9
ha_addon/rootfs/etc/services.d/nginx/finish
Executable file
9
ha_addon/rootfs/etc/services.d/nginx/finish
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Log Viewer
|
||||
# Take down the S6 supervision tree when Nginx fails
|
||||
# ==============================================================================
|
||||
if { s6-test ${1} -ne 0 }
|
||||
if { s6-test ${1} -ne 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
31
ha_addon/rootfs/etc/services.d/nginx/run
Executable file
31
ha_addon/rootfs/etc/services.d/nginx/run
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/command/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Scrypted
|
||||
# Runs the Nginx daemon
|
||||
# ==============================================================================
|
||||
|
||||
# Wait for the Scrypted service to become available
|
||||
declare name
|
||||
declare value
|
||||
bashio::net.wait_for 10443
|
||||
|
||||
bashio::log.info "Starting NGinx..."
|
||||
for var in $(bashio::config 'env_vars|keys'); do
|
||||
name=$(bashio::config "env_vars[${var}].name")
|
||||
value=$(bashio::config "env_vars[${var}].value")
|
||||
bashio::log.info "Setting ${name} in nginx run"
|
||||
export "${name}=${value}"
|
||||
done
|
||||
|
||||
|
||||
if [[ ! -v SCRYPTED_ADMIN_TOKEN || -z "$SCRYPTED_ADMIN_TOKEN" ]];
|
||||
then
|
||||
bashio::log.info "No SCRYPTED_ADMIN_TOKEN setting found, removing proxy_pass_header config."
|
||||
sed -i "s/.*Authorization.*//g" /etc/nginx/servers/ingress.conf
|
||||
else
|
||||
bashio::log.info "SCRYPTED_ADMIN_TOKEN setting found, adding proxy_pass_header config."
|
||||
sed -i "s/%%authorization_header%%/$SCRYPTED_ADMIN_TOKEN/g" /etc/nginx/servers/ingress.conf
|
||||
fi
|
||||
|
||||
|
||||
exec nginx
|
||||
9
ha_addon/rootfs/etc/services.d/scrypted-run/finish
Executable file
9
ha_addon/rootfs/etc/services.d/scrypted-run/finish
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Log Viewer
|
||||
# Take down the S6 supervision tree when Log Viewer fails
|
||||
# ==============================================================================
|
||||
if -n { s6-test $# -ne 0 }
|
||||
if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
29
ha_addon/rootfs/etc/services.d/scrypted-run/run
Executable file
29
ha_addon/rootfs/etc/services.d/scrypted-run/run
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/command/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Log Viewer
|
||||
# Runs the Log Viewer
|
||||
# ==============================================================================
|
||||
declare name
|
||||
declare value
|
||||
bashio::log.info "Starting Scrypted..."
|
||||
|
||||
# Ensure the configuration exists
|
||||
if bashio::fs.file_exists '/data/config/options.json'; then
|
||||
cp -f -v /data/config/options.json /etc/options
|
||||
else
|
||||
mkdir -p -v /data/config \
|
||||
|| bashio::exit.nok "Failed to create the Scrypted configuration directory"
|
||||
|
||||
# Copy in template file
|
||||
cp -v /etc/options.json /data/config/
|
||||
fi
|
||||
|
||||
|
||||
for var in $(bashio::config 'env_vars|keys'); do
|
||||
name=$(bashio::config "env_vars[${var}].name")
|
||||
value=$(bashio::config "env_vars[${var}].value")
|
||||
bashio::log.info "Setting ${name} in scrypted run"
|
||||
export "${name}=${value}"
|
||||
done
|
||||
|
||||
cd /server && npm exec scrypted-serve
|
||||
@@ -42,7 +42,7 @@ fi
|
||||
WATCHTOWER_HTTP_API_TOKEN=$(echo $RANDOM | md5sum)
|
||||
DOCKER_COMPOSE_YML=$SCRYPTED_HOME/docker-compose.yml
|
||||
echo "Created $DOCKER_COMPOSE_YML"
|
||||
curl -s https://raw.githubusercontent.com/koush/scrypted/main/docker/docker-compose.yml | sed s/SET_THIS_TO_SOME_RANDOM_TEXT/"$(echo $RANDOM | md5sum | head -c 32)"/g > $DOCKER_COMPOSE_YML
|
||||
curl -s https://raw.githubusercontent.com/koush/scrypted/main/install/docker/docker-compose.yml | sed s/SET_THIS_TO_SOME_RANDOM_TEXT/"$(echo $RANDOM | md5sum | head -c 32)"/g > $DOCKER_COMPOSE_YML
|
||||
|
||||
echo "Setting permissions on $SCRYPTED_HOME"
|
||||
chown -R $SERVICE_USER $SCRYPTED_HOME
|
||||
@@ -48,7 +48,7 @@ ENV() {
|
||||
echo "ignoring ENV $1"
|
||||
}
|
||||
|
||||
source <(curl -s https://raw.githubusercontent.com/koush/scrypted/main/docker/template/Dockerfile.full.header)
|
||||
source <(curl -s https://raw.githubusercontent.com/koush/scrypted/main/install/docker/template/Dockerfile.full.header)
|
||||
|
||||
if [ -z "$SERVICE_USER" ]
|
||||
then
|
||||
@@ -98,8 +98,6 @@ export function getCurrentBaseUrl() {
|
||||
// an endpoint within scrypted will be served at /endpoint/[org/][id]
|
||||
// find the endpoint prefix and anything prior to that will be the server base url.
|
||||
const url = new URL(window.location.href);
|
||||
url.search = '';
|
||||
url.hash = '';
|
||||
let endpointPath = window.location.pathname;
|
||||
const parts = endpointPath.split('/');
|
||||
const index = parts.findIndex(p => p === 'endpoint');
|
||||
|
||||
4
server/package-lock.json
generated
4
server/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.10.0",
|
||||
"version": "0.11.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.10.0",
|
||||
"version": "0.11.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@mapbox/node-pre-gyp": "^1.0.10",
|
||||
|
||||
Reference in New Issue
Block a user