diff --git a/scrutiny/config.json b/scrutiny/config.json index cdbdd6bd2..3760838c7 100644 --- a/scrutiny/config.json +++ b/scrutiny/config.json @@ -16,7 +16,6 @@ "ports_description": { "8080/tcp": "Web UI port" }, - "full_access": true, "devices": [ "/dev/sda", "/dev/sdb", diff --git a/scrutiny_fa/CHANGELOG.md b/scrutiny_fa/CHANGELOG.md new file mode 100644 index 000000000..b0d577a34 --- /dev/null +++ b/scrutiny_fa/CHANGELOG.md @@ -0,0 +1,32 @@ +- Added full access. Use only if you can't connect without +- New standardized logic for Dockerfile build and packages installation +- Added : "/dev/nvme0" + +## 0.3.13 (26-10-2021) + +- Update to latest version from analogj/scrutiny +- Allow mounting of devices up to sdg2 + +## 0.3.12 (29-09-2021) + +- Update to latest version from AnalogJ/scrutiny +- Aligned with AnalogJ namings + +## fd4f0429 + +- New ingress icon, thanks to @ElVit +- New features, selecting of update rate with addon option +- Add banner in log +- Align to upstream + +## 27b923b5-ls12 + +- Removed full access flag +- Improved code for local devices scanning after first installation +- Solved an issue that made a blank screen on mobile devices +- Implementation of Ingress with/without ssl + +## 27b923b5-ls11 + +- Enables PUID/GUID options +- Daily update of values diff --git a/scrutiny_fa/Dockerfile b/scrutiny_fa/Dockerfile new file mode 100644 index 000000000..f75d3d84f --- /dev/null +++ b/scrutiny_fa/Dockerfile @@ -0,0 +1,105 @@ +#============================# +# ALEXBELGIUM'S DOCKERFILE # +#============================# +# _.------. +# _.-` ('>.-`"""-. +# '.--'` _'` _ .--.) +# -' '-.-';` ` +# ' - _.' ``'--. +# '---` .-'""` +# /` +#=== Home Assistant Addon ===# + +################# +# 1 Build Image # +################# + +ARG BUILD_FROM +ARG BUILD_VERSION +FROM ${BUILD_FROM} + +################## +# 2 Modify Image # +################## + +# hadolint ignore=DL4006 +RUN \ + # Allow UID and GID setting + sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ + # use /data instead of /config for database + && sed -i 's| /config| /data|g' /defaults/scrutiny.yaml \ + && sed -i 's| /config| /data|g' /etc/cont-init.d/* \ + && sed -i 's| /config| /data|g' /etc/logrotate.d/scrutiny \ + && sed -i 's| /config| /data|g' /etc/crontabs/root \ + # correct url paths + && grep -rl '/web/' /app/scrutiny-web/ | xargs sed -i 's|/web/|./|g' + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Modules +ARG MODULES="00-banner.sh" + +# Automatic modules download +RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && mkdir -p /etc/cont-init.d \ + && for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \ + && chmod -R 755 /etc/cont-init.d || printf '%s\n' "${MODULES}" >/MODULESFILE + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + nginx" + +# Automatic apps & bashio +RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \ + && chmod 777 /automatic_packages.sh \ + && eval /./automatic_packages.sh "${PACKAGES:-}" \ + && rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +# Collector +RUN chmod 777 /run.sh + +############ +# 5 Labels # +############ + +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_DESCRIPTION +ARG BUILD_NAME +ARG BUILD_REF +ARG BUILD_REPOSITORY +ARG BUILD_VERSION +LABEL \ + io.hass.name="${BUILD_NAME}" \ + io.hass.description="${BUILD_DESCRIPTION}" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.title="${BUILD_NAME}" \ + org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ + org.opencontainers.image.vendor="Home Assistant Add-ons" \ + org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.url="https://github.com/alexbelgium" \ + org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ + org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ + org.opencontainers.image.created=${BUILD_DATE} \ + org.opencontainers.image.revision=${BUILD_REF} \ + org.opencontainers.image.version=${BUILD_VERSION} diff --git a/scrutiny_fa/README.md b/scrutiny_fa/README.md new file mode 100644 index 000000000..96513fd68 --- /dev/null +++ b/scrutiny_fa/README.md @@ -0,0 +1,112 @@ +# Home assistant add-on: Scrutiny + +[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium) + +![Version](https://img.shields.io/badge/dynamic/json?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fscrutiny%2Fconfig.json) +![Ingress](https://img.shields.io/badge/dynamic/json?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fscrutiny%2Fconfig.json) +![Arch](https://img.shields.io/badge/dynamic/json?color=success&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fscrutiny%2Fconfig.json) + +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9c6cf10bdbba45ecb202d7f579b5be0e)](https://www.codacy.com/gh/alexbelgium/hassio-addons/dashboard?utm_source=github.com&utm_medium=referral&utm_content=alexbelgium/hassio-addons&utm_campaign=Badge_Grade) +[![GitHub Super-Linter](https://github.com/alexbelgium/hassio-addons/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter) +[![Builder](https://github.com/alexbelgium/hassio-addons/workflows/Builder/badge.svg)](https://github.com/alexbelgium/hassio-addons/actions/workflows/builder.yaml) + +[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white + +_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_ + +[![Stargazers repo roster for @alexbelgium/hassio-addons](https://reporoster.com/stars/alexbelgium/hassio-addons)](https://github.com/alexbelgium/hassio-addons/stargazers) + +## About + +--- + +[Scrutiny](https://github.com/AnalogJ/scrutiny) is a Hard Drive Health Dashboard & Monitoring solution, merging manufacturer provided S.M.A.R.T metrics with real-world failure rates. This addon is based on the [docker image](https://hub.docker.com/r/linuxserver/scrutiny) from [linuxserver.io](https://www.linuxserver.io/). + +Features : + +- SMART monitoring +- Automatic addition of local drives +- Hourly updates +- Ingress with/without ssl +- Automatic upstream updates + +## Configuration + +--- + +Webui can be found at , or through Ingress. +It automatically mounts all local drives. + +Enable full access only if you are encountering issues. SMART access should work without full access in all other scenarios. + +```yaml +GUID: user +GPID: user +ssl: true/false (for Ingress) +certfile: fullchain.pem #ssl certificate +keyfile: privkey.pem #sslkeyfile +``` + +## Installation + +--- + +The installation of this add-on is pretty straightforward and not different in comparison to installing any other add-on. + +1. [Add my Hass.io add-ons repository][repository] to your home assistant instance. +1. Install this add-on. +1. Click the `Save` button to store your configuration. +1. Set the add-on options to your preferences +1. Start the add-on. +1. Check the logs of the add-on to see if everything went well. +1. Open the webUI (Ingress based) and adapt the software options + +# Integration in home assistant + +--- + +Integration with HA can be done with the [rest platform](https://www.home-assistant.io/integrations/rest) in configuration.yaml. + +Two types of api endpoints are available: + +- Summary data : http://YOURIP:ADDONPORT/api/summary +- Detailed data : http://YOURIP:ADDONPORT/api/WWN/details + +For the detailed data, wmn can be found for each hdd within the scrutiny app. For example for me : http://192.168.178.23:8086/api/device/0x50014ee606c14537/details + +Example to get data from the first hdd. + +```yaml +rest: + - verify_ssl: false + scan_interval: 60 + resource: http://YOURIP:ADDONPORT/api/summary + sensor: + - name: "HDD disk 1" + json_attributes_path: "$.data[0].smart_results[0]" + value_template: "OK" + json_attributes: + - "device_wwn" + - "date" + - "smart_status" + - "temp" + - "power_on_hours" + - "power_cycle_count" + - "ata_attributes" + - "nvme_attributes" + - "scsi_attributes" +``` + +## Illustration + +--- + +![Illustration](https://github.com/AnalogJ/scrutiny/raw/master/docs/dashboard.png) + +## Support + +Create an issue on github, or ask on the [home assistant thread](https://community.home-assistant.io/t/home-assistant-addon-scrutiny-smart-dashboard/295747) + +https://github.com/alexbelgium/hassio-addons + +[repository]: https://github.com/alexbelgium/hassio-addons diff --git a/scrutiny_fa/apparmor.txt b/scrutiny_fa/apparmor.txt new file mode 100644 index 000000000..08a51a81f --- /dev/null +++ b/scrutiny_fa/apparmor.txt @@ -0,0 +1,68 @@ +#include + +profile db21ed7f_scrutiny flags=(attach_disconnected,mediate_deleted) { + #include + + capability, + file, + signal, + mount, + umount, + remount, + network udp, + network tcp, + network dgram, + network stream, + network inet, + network inet6, + network netlink raw, + + capability setgid, + capability setuid, + capability dac_override, + capability sys_admin, + capability dac_read_search, + capability sys_rawio, + +# S6-Overlay + /bin/** ix, + /usr/bin/** ix, + /usr/lib/bashio/** ix, + /etc/s6/** rix, + /run/s6/** rix, + /etc/services.d/** rwix, + /etc/cont-init.d/** rwix, + /etc/cont-finish.d/** rwix, + /init rix, + /var/run/** mrwkl, + /var/run/ mrwkl, + /dev/i2c-1 mrwkl, + # Files required + /dev/sda1 mrwkl, + /dev/sdb1 mrwkl, + /dev/mmcblk0p1 mrwkl, + /dev/* mrwkl, + /tmp/** mrkwl, + /dev/sda mrwkl, + /dev/sdb mrwkl, + /dev/sdc mrwkl, + /dev/sdd mrwkl, + /dev/sde mrwkl, + /dev/sdf mrwkl, + /dev/sdg mrwkl, + /dev/nvme0 mrwkl, + /dev/nvme1 mrwkl, + /dev/nvme2 mrwkl, + /dev/nvme3 mrwkl, + /dev/nvme4 mrwkl, + + # Data access + /data/** rw, + + # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container + ptrace (trace,read) peer=docker-default, + + # docker daemon confinement requires explict allow rule for signal + signal (receive) set=(kill,term) peer=/usr/bin/docker, + +} diff --git a/scrutiny_fa/build.json b/scrutiny_fa/build.json new file mode 100644 index 000000000..4fc0e6a89 --- /dev/null +++ b/scrutiny_fa/build.json @@ -0,0 +1,7 @@ +{ + "build_from": { + "armv7": "lscr.io/linuxserver/scrutiny:arm32v7-latest", + "aarch64": "lscr.io/linuxserver/scrutiny:arm64v8-latest", + "amd64": "lscr.io/linuxserver/scrutiny:amd64-latest" + } +} diff --git a/scrutiny_fa/config.json b/scrutiny_fa/config.json new file mode 100644 index 000000000..0882a2a8c --- /dev/null +++ b/scrutiny_fa/config.json @@ -0,0 +1,46 @@ +{ + "name": "Scrutiny (Full Access)", + "version": "0.3.13-7", + "upstream": "0.3.13", + "slug": "scrutiny_fa", + "description": "Scrutiny WebUI for smartd S.M.A.R.T monitoring (Full Access)", + "url": "https://github.com/AnalogJ/scrutiny", + "startup": "services", + "arch": ["aarch64", "amd64", "armv7"], + "ingress": true, + "ingress_port": 8099, + "panel_icon": "mdi:glasses", + "ports": { + "8080/tcp": 8086 + }, + "ports_description": { + "8080/tcp": "Web UI port" + }, + "full_access": true, + "udev": "true", + "apparmor": "true", + "map": [], + "boot": "auto", + "environment": { + "SCRUTINY_API_ENDPOINT": "http://localhost:8080", + "SCRUTINY_WEB": "true", + "SCRUTINY_COLLECTOR": "true" + }, + "options": { + "ssl": false, + "certfile": "fullchain.pem", + "keyfile": "privkey.pem", + "Updates": "Hourly", + "PUID": 0, + "PGID": 0 + }, + "schema": { + "ssl": "bool", + "certfile": "str", + "keyfile": "str", + "Updates": "list(|Hourly|Daily|Weekly)", + "PUID": "int", + "PGID": "int", + "TZ": "str?" + } +} diff --git a/scrutiny_fa/icon.png b/scrutiny_fa/icon.png new file mode 100644 index 000000000..0ba94a22a Binary files /dev/null and b/scrutiny_fa/icon.png differ diff --git a/scrutiny_fa/logo.png b/scrutiny_fa/logo.png new file mode 100644 index 000000000..0ba94a22a Binary files /dev/null and b/scrutiny_fa/logo.png differ diff --git a/scrutiny_fa/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/scrutiny_fa/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..98dddfe70 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && mkdir -p /etc/cont-init.d \ + && for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \ + && chmod -R 755 /etc/cont-init.d +fi + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \ + && chmod 777 /automatic_packages.sh \ + && eval /./automatic_packages.sh "${PACKAGES:-}" \ + && rm /automatic_packages.sh +fi diff --git a/scrutiny_fa/rootfs/etc/cont-init.d/31-run.sh b/scrutiny_fa/rootfs/etc/cont-init.d/31-run.sh new file mode 100644 index 000000000..4947166c4 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/cont-init.d/31-run.sh @@ -0,0 +1,50 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +############## +# Data usage # +############## + +bashio::log.info "Setting permissions" +chown -R abc:abc /data + +####################### +# VIEWPORT CORRECTION # +####################### + +# correct viewport bug +# grep -rl '"lt-md":"(max-width: 959px)"' /app | xargs sed -i 's|"lt-md":"(max-width: 959px)"|"lt-md":"(max-width: 100px)"|g' || true + +###################### +# API URL CORRECTION # +###################### + +# allow true url for ingress +grep -rl '/api/' /app | xargs sed -i 's|/api/|api/|g' || true +grep -rl 'api/' /app | xargs sed -i 's|api/|./api/|g' || true + +################ +# CRON OPTIONS # +################ + +rm /config/crontabs/* || true +sed -i '$d' /etc/crontabs/root +sed -i -e '$a @reboot /run.sh' /etc/crontabs/root + +# Align update with options +FREQUENCY=$(bashio::config 'Updates') +bashio::log.info "$FREQUENCY updates" + +case $FREQUENCY in +"Hourly") + sed -i -e '$a 0 * * * * /run.sh' /etc/crontabs/root + ;; + +"Daily") + sed -i -e '$a 0 0 * * * /run.sh' /etc/crontabs/root + ;; + +"Weekly") + sed -i -e '$a 0 0 * * 0 /run.sh' /etc/crontabs/root + ;; +esac diff --git a/scrutiny_fa/rootfs/etc/cont-init.d/32-nginx.sh b/scrutiny_fa/rootfs/etc/cont-init.d/32-nginx.sh new file mode 100644 index 000000000..6ac38a5b6 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/cont-init.d/32-nginx.sh @@ -0,0 +1,33 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare port +declare certfile +declare ingress_interface +declare ingress_port +declare keyfile + +port=$(bashio::addon.port 80) +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) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf diff --git a/scrutiny_fa/rootfs/etc/nginx/includes/mime.types b/scrutiny_fa/rootfs/etc/nginx/includes/mime.types new file mode 100644 index 000000000..7c7cdef2d --- /dev/null +++ b/scrutiny_fa/rootfs/etc/nginx/includes/mime.types @@ -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; +} diff --git a/scrutiny_fa/rootfs/etc/nginx/includes/proxy_params.conf b/scrutiny_fa/rootfs/etc/nginx/includes/proxy_params.conf new file mode 100644 index 000000000..1990d4959 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/nginx/includes/proxy_params.conf @@ -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; diff --git a/scrutiny_fa/rootfs/etc/nginx/includes/resolver.conf b/scrutiny_fa/rootfs/etc/nginx/includes/resolver.conf new file mode 100644 index 000000000..6485af141 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/nginx/includes/resolver.conf @@ -0,0 +1 @@ +resolver 127.0.0.11; diff --git a/scrutiny_fa/rootfs/etc/nginx/includes/server_params.conf b/scrutiny_fa/rootfs/etc/nginx/includes/server_params.conf new file mode 100644 index 000000000..09c06543e --- /dev/null +++ b/scrutiny_fa/rootfs/etc/nginx/includes/server_params.conf @@ -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; diff --git a/scrutiny_fa/rootfs/etc/nginx/includes/ssl_params.conf b/scrutiny_fa/rootfs/etc/nginx/includes/ssl_params.conf new file mode 100644 index 000000000..6f1500599 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/nginx/includes/ssl_params.conf @@ -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; diff --git a/scrutiny_fa/rootfs/etc/nginx/includes/upstream.conf b/scrutiny_fa/rootfs/etc/nginx/includes/upstream.conf new file mode 100644 index 000000000..b292326bd --- /dev/null +++ b/scrutiny_fa/rootfs/etc/nginx/includes/upstream.conf @@ -0,0 +1,3 @@ +upstream backend { + server 127.0.0.1:8080; +} diff --git a/scrutiny_fa/rootfs/etc/nginx/nginx.conf b/scrutiny_fa/rootfs/etc/nginx/nginx.conf new file mode 100644 index 000000000..7e5bc6f7c --- /dev/null +++ b/scrutiny_fa/rootfs/etc/nginx/nginx.conf @@ -0,0 +1,56 @@ +# 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 Hass.io add-on log. +error_log /proc/1/fd/1 error; + +# Load allowed environment vars +env HASSIO_TOKEN; + +# 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 hassio '[$time_local] $status ' + '$http_x_forwarded_for($remote_addr) ' + '$request ($http_user_agent)'; + + access_log /proc/1/fd/1 hassio; + client_max_body_size 4G; + default_type application/octet-stream; + gzip on; + keepalive_timeout 65; + sendfile on; + server_tokens off; + tcp_nodelay on; + tcp_nopush on; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + include /etc/nginx/includes/resolver.conf; + include /etc/nginx/includes/upstream.conf; + + include /etc/nginx/servers/*.conf; +} diff --git a/scrutiny_fa/rootfs/etc/nginx/servers/ingress.conf b/scrutiny_fa/rootfs/etc/nginx/servers/ingress.conf new file mode 100644 index 000000000..6c82c3dc5 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/nginx/servers/ingress.conf @@ -0,0 +1,21 @@ +server { + listen %%interface%%:%%port%% default_server; + + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + + client_max_body_size 0; + + location / { + add_header Access-Control-Allow-Origin *; + proxy_read_timeout 30; + proxy_pass http://backend/web/; + } + + location /api/ { + add_header Access-Control-Allow-Origin *; + proxy_read_timeout 30; + proxy_pass http://backend/api/; + } + +} diff --git a/scrutiny_fa/rootfs/etc/services.d/nginx/finish b/scrutiny_fa/rootfs/etc/services.d/nginx/finish new file mode 100644 index 000000000..444240135 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/services.d/nginx/finish @@ -0,0 +1,8 @@ +#!/usr/bin/execlineb -S0 +# ============================================================================== +# 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 diff --git a/scrutiny_fa/rootfs/etc/services.d/nginx/run b/scrutiny_fa/rootfs/etc/services.d/nginx/run new file mode 100644 index 000000000..07447d8b8 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/services.d/nginx/run @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== + +# Wait for transmission to become available +bashio::net.wait_for 8080 localhost 900 + +bashio::log.info "Starting NGinx..." + +exec nginx diff --git a/scrutiny_fa/rootfs/run.sh b/scrutiny_fa/rootfs/run.sh new file mode 100644 index 000000000..30bc73d68 --- /dev/null +++ b/scrutiny_fa/rootfs/run.sh @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# wait for scrutiny to load +bashio::net.wait_for 8080 + +##################### +# ADD LOCAL DEVICES # +##################### + +# search for local devices +# shellcheck disable=SC2015 +scrutiny-collector-metrics run >/dev/null && bashio::log.info "Local Devices Added" || bashio::log.error "Local Devices Not Added"