Cleanup commit
This commit is contained in:
commit
7cef46e0d4
24
.devcontainer/devcontainer.json
Normal file
24
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "Example devcontainer for add-on repositories",
|
||||
"image": "ghcr.io/home-assistant/devcontainer:addons",
|
||||
"appPort": ["7123:8123", "7357:4357"],
|
||||
"postStartCommand": "bash devcontainer_bootstrap",
|
||||
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
|
||||
"containerEnv": {
|
||||
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
|
||||
},
|
||||
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"],
|
||||
"mounts": [ "type=volume,target=/var/lib/docker" ],
|
||||
"settings": {
|
||||
"terminal.integrated.profiles.linux": {
|
||||
"zsh": {
|
||||
"path": "/usr/bin/zsh"
|
||||
}
|
||||
},
|
||||
"terminal.integrated.defaultProfile.linux": "zsh",
|
||||
"editor.formatOnPaste": false,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnType": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
}
|
||||
}
|
||||
54
.github/workflows/3dprinter-octoprint.yml
vendored
Normal file
54
.github/workflows/3dprinter-octoprint.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
name: 3dprinter-octoprint manual build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
|
||||
strategy:
|
||||
matrix:
|
||||
addon: ["3dprinter-octoprint"]
|
||||
arch: ["aarch64", "amd64", "armhf", "armv7"]
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get information
|
||||
id: info
|
||||
uses: home-assistant/actions/helpers/info@master
|
||||
with:
|
||||
path: "./${{ matrix.addon }}"
|
||||
|
||||
- name: Check if add-on should be built
|
||||
id: check
|
||||
run: |
|
||||
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
|
||||
echo "::set-output name=build_arch::true";
|
||||
echo "::set-output name=image::$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)";
|
||||
else
|
||||
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build";
|
||||
echo "::set-output name=build_arch::false";
|
||||
fi
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: env.BUILD_ARGS != '--test'
|
||||
uses: docker/login-action@v2.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build ${{ matrix.addon }} add-on
|
||||
if: steps.check.outputs.build_arch == 'true'
|
||||
uses: home-assistant/builder@2022.03.1
|
||||
with:
|
||||
args: |
|
||||
${{ env.BUILD_ARGS }} \
|
||||
--${{ matrix.arch }} \
|
||||
--target /data/${{ matrix.addon }} \
|
||||
--image "${{ steps.check.outputs.image }}" \
|
||||
--docker-hub "ghcr.io/${{ github.repository_owner }}" \
|
||||
--addon \
|
||||
--docker-hub-check
|
||||
54
.github/workflows/camera-aiortc.yml
vendored
Normal file
54
.github/workflows/camera-aiortc.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
name: camera-rtc manual build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
|
||||
strategy:
|
||||
matrix:
|
||||
addon: ["camera-rtc"]
|
||||
arch: ["aarch64", "amd64", "armhf", "armv7"]
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get information
|
||||
id: info
|
||||
uses: home-assistant/actions/helpers/info@master
|
||||
with:
|
||||
path: "./${{ matrix.addon }}"
|
||||
|
||||
- name: Check if add-on should be built
|
||||
id: check
|
||||
run: |
|
||||
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
|
||||
echo "::set-output name=build_arch::true";
|
||||
echo "::set-output name=image::$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)";
|
||||
else
|
||||
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build";
|
||||
echo "::set-output name=build_arch::false";
|
||||
fi
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: env.BUILD_ARGS != '--test'
|
||||
uses: docker/login-action@v2.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build ${{ matrix.addon }} add-on
|
||||
if: steps.check.outputs.build_arch == 'true'
|
||||
uses: home-assistant/builder@2022.03.1
|
||||
with:
|
||||
args: |
|
||||
${{ env.BUILD_ARGS }} \
|
||||
--${{ matrix.arch }} \
|
||||
--target /data/${{ matrix.addon }} \
|
||||
--image "${{ steps.check.outputs.image }}" \
|
||||
--docker-hub "ghcr.io/${{ github.repository_owner }}" \
|
||||
--addon \
|
||||
--docker-hub-check
|
||||
54
.github/workflows/camera-mjpg-streamer.yml
vendored
Normal file
54
.github/workflows/camera-mjpg-streamer.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
name: camera-mjpg-streamer manual build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
|
||||
strategy:
|
||||
matrix:
|
||||
addon: ["camera-mjpg-streamer"]
|
||||
arch: ["aarch64", "amd64", "armhf", "armv7", "i386"]
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get information
|
||||
id: info
|
||||
uses: home-assistant/actions/helpers/info@master
|
||||
with:
|
||||
path: "./${{ matrix.addon }}"
|
||||
|
||||
- name: Check if add-on should be built
|
||||
id: check
|
||||
run: |
|
||||
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
|
||||
echo "::set-output name=build_arch::true";
|
||||
echo "::set-output name=image::$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)";
|
||||
else
|
||||
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build";
|
||||
echo "::set-output name=build_arch::false";
|
||||
fi
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: env.BUILD_ARGS != '--test'
|
||||
uses: docker/login-action@v2.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build ${{ matrix.addon }} add-on
|
||||
if: steps.check.outputs.build_arch == 'true'
|
||||
uses: home-assistant/builder@2022.03.1
|
||||
with:
|
||||
args: |
|
||||
${{ env.BUILD_ARGS }} \
|
||||
--${{ matrix.arch }} \
|
||||
--target /data/${{ matrix.addon }} \
|
||||
--image "${{ steps.check.outputs.image }}" \
|
||||
--docker-hub "ghcr.io/${{ github.repository_owner }}" \
|
||||
--addon \
|
||||
--docker-hub-check
|
||||
22
.github/workflows/cleanup-packages.yml
vendored
Normal file
22
.github/workflows/cleanup-packages.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: cleanup-packages
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
name: Cleanup packages
|
||||
steps:
|
||||
- name: Delete old packages
|
||||
uses: smartsquaregmbh/delete-old-packages@v0.6.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
user: fredrikbaberg
|
||||
type: container
|
||||
keep: 5
|
||||
names: |
|
||||
ha-addon-3dprinter-octoprint-aarch64
|
||||
ha-addon-3dprinter-octoprint-amd64
|
||||
ha-addon-3dprinter-octoprint-armhf
|
||||
ha-addon-3dprinter-octoprint-armv7
|
||||
19
.vscode/tasks.json
vendored
Normal file
19
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Start Home Assistant",
|
||||
"type": "shell",
|
||||
"command": "sudo chmod a+x /usr/bin/supervisor* && sudo -E supervisor_run",
|
||||
"group": {
|
||||
"kind": "test",
|
||||
"isDefault": true
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new"
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
7
3dprinter-octoprint/CHANGELOG.md
Normal file
7
3dprinter-octoprint/CHANGELOG.md
Normal file
@ -0,0 +1,7 @@
|
||||
## 2023.01.0
|
||||
* Update to OctoPrint 1.8.6.
|
||||
* Disabled Ingress.
|
||||
* Based on Debian instead of Alpine, should make more plugins compatible.
|
||||
* Default config now set by CLI instead of copying pre-set file.
|
||||
* Using Caddy as reverse proxy.
|
||||
* Added option to set trusted_proxies, should help with reverse proxy configuration.
|
||||
25
3dprinter-octoprint/DOCS.md
Normal file
25
3dprinter-octoprint/DOCS.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Addon configuration
|
||||
|
||||
## Trusted proxies
|
||||
|
||||
By setting trusted proxies you should be able to use HTTPS *if you have placed a reverse proxy in front of Home Assistant*. For more information, see [Caddy documentation](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy).
|
||||
|
||||
# Camera
|
||||
|
||||
There is no camera server in the addon, it has to be setup separately.
|
||||
|
||||
You could, for instance, use the addon [camera-mjpg-streamer](https://github.com/fredrikbaberg/3dprinter-addons/tree/main/camera-mjpg-streamer) available in the same repository. If so, you can set the snapshot URL to:
|
||||
> `http://b7aa59c4-camera-mjpg-streamer/?action=snapshot`.
|
||||
|
||||
Note that this method **only allows for snapshot**, it does **NOT** work for camera stream as this requires the browser/app used to directly access the stream.
|
||||
|
||||
# Ingress?
|
||||
|
||||
This addon drops support for Ingress. The main reason for this is issues with finding a working configuration.
|
||||
|
||||
* An update to OctoPrint increased the security (which is good!). Unfortunately it also broke the configuration used in this addon, most likely due to this addon not behaving properly.
|
||||
* There has been issues with accessing camera stream by Ingress since I added support for it, which I have not been able to solve.
|
||||
|
||||
I have tried to find a solution to this, without success. Therefore I decided to disable the option, as it just leads to frustration.
|
||||
|
||||
If someone is able to find a working configuration, please let me know.
|
||||
46
3dprinter-octoprint/Dockerfile
Normal file
46
3dprinter-octoprint/Dockerfile
Normal file
@ -0,0 +1,46 @@
|
||||
ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye"
|
||||
FROM ${BUILD_FROM}
|
||||
ARG OCTOPRINT_VERSION="1.8.6"
|
||||
|
||||
# Setup path for persistent install of Python packages
|
||||
ENV PYTHONPATH=/data/python/octoprint
|
||||
ENV PYTHONUSERBASE=/data/python/octoprint
|
||||
ENV PATH=/data/python/octoprint/bin:${PATH}
|
||||
ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION}
|
||||
|
||||
# Preparation for install of Caddy
|
||||
RUN apt update \
|
||||
&& apt install -y \
|
||||
--no-install-recommends \
|
||||
debian-keyring \
|
||||
debian-archive-keyring \
|
||||
apt-transport-https \
|
||||
gpg \
|
||||
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \
|
||||
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
|
||||
|
||||
# Install dependencies
|
||||
RUN apt update \
|
||||
&& apt install -y \
|
||||
--no-install-recommends \
|
||||
python3-venv \
|
||||
python3-dev \
|
||||
python3-wheel \
|
||||
build-essential \
|
||||
caddy \
|
||||
# Extras.
|
||||
ffmpeg \
|
||||
# avrdude \
|
||||
# dfu-util \
|
||||
# dfu-programmer \
|
||||
# stm32flash \
|
||||
# Development/testing
|
||||
vim \
|
||||
&& \
|
||||
apt clean
|
||||
|
||||
# Copy root filesystem
|
||||
COPY rootfs /
|
||||
RUN chmod +x /etc/cont-init.d/*.sh
|
||||
RUN chmod +x /etc/services.d/*/*
|
||||
RUN chmod +x /scripts/*.sh
|
||||
6
3dprinter-octoprint/README.md
Normal file
6
3dprinter-octoprint/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# 3DPrinter-OctoPrint
|
||||
|
||||
Provides OctoPrint as an addon to Home Assistant.
|
||||
|
||||
Note: Ingress is **NOT** supported.
|
||||
|
||||
12
3dprinter-octoprint/build.yaml
Normal file
12
3dprinter-octoprint/build.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
build_from:
|
||||
aarch64: ghcr.io/home-assistant/aarch64-base-debian:bullseye
|
||||
amd64: ghcr.io/home-assistant/amd64-base-debian:bullseye
|
||||
armhf: ghcr.io/home-assistant/armhf-base-debian:bullseye
|
||||
armv7: ghcr.io/home-assistant/armv7-base-debian:bullseye
|
||||
i386: ghcr.io/home-assistant/i386-base-debian:bullseye
|
||||
labels:
|
||||
org.opencontainers.image.title: "Home Assistant Add-on: 3DPrinter-OctoPrint"
|
||||
org.opencontainers.image.description: "3DPrinter-OctoPrint addon for Home-Assistant."
|
||||
org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons"
|
||||
args:
|
||||
OCTOPRINT_VERSION: "1.8.6"
|
||||
35
3dprinter-octoprint/config.yaml
Normal file
35
3dprinter-octoprint/config.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
name: "3DPrinter-OctoPrint"
|
||||
version: "2023.01.0"
|
||||
slug: "3dprinter-octoprint"
|
||||
description: "OctoPrint as an addon, no additional bells and whistles."
|
||||
url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint"
|
||||
ingress: false
|
||||
ingress_stream: false
|
||||
panel_icon: mdi:printer-3d
|
||||
panel_title: 3DPrinter-OctoPrint
|
||||
arch:
|
||||
- armv7
|
||||
- amd64
|
||||
- armhf
|
||||
- aarch64
|
||||
- i386
|
||||
stage: experimental
|
||||
init: false
|
||||
realtime: true
|
||||
gpio: true
|
||||
uart: true
|
||||
usb: true
|
||||
ports:
|
||||
5000/tcp: null
|
||||
ports_description:
|
||||
5000/tcp: Web-based interface
|
||||
options:
|
||||
trusted_proxies: ""
|
||||
# camera_url: "http://b7aa59c4-camera-mjpg-streamer"
|
||||
# mode: normal
|
||||
schema:
|
||||
trusted_proxies: "str?"
|
||||
# camera_url: "url?"
|
||||
# mode: "list(normal|recovery|reverse_proxy_test|camera)?"
|
||||
tmpfs: true
|
||||
image: ghcr.io/fredrikbaberg/ha-addon-3dprinter-octoprint-{arch}
|
||||
BIN
3dprinter-octoprint/icon.png
Normal file
BIN
3dprinter-octoprint/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
BIN
3dprinter-octoprint/logo.png
Normal file
BIN
3dprinter-octoprint/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
10
3dprinter-octoprint/rootfs/etc/caddy/Caddyfile
Normal file
10
3dprinter-octoprint/rootfs/etc/caddy/Caddyfile
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
# debug
|
||||
log {
|
||||
format console
|
||||
output file /var/log/caddy/caddy.log
|
||||
}
|
||||
auto_https disable_redirects
|
||||
}
|
||||
|
||||
import sites-enabled/*.caddy
|
||||
2
3dprinter-octoprint/rootfs/etc/caddy/env
Normal file
2
3dprinter-octoprint/rootfs/etc/caddy/env
Normal file
@ -0,0 +1,2 @@
|
||||
XDG_CONFIG_HOME="/data/config"
|
||||
XDG_DATA_HOME="/data/config"
|
||||
0
3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitignore
vendored
Normal file
0
3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitignore
vendored
Normal file
54
3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh
Normal file
54
3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh
Normal file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Prepare OctoPrint
|
||||
# s6-overlay docs: https://github.com/just-containers/s6-overlay
|
||||
# ==============================================================================
|
||||
export BASEDIR="--basedir /data/config/octoprint"
|
||||
|
||||
{ # Check if OctoPrint is installed.
|
||||
octoprint $BASEDIR --version
|
||||
} || { # Otherwise install it.
|
||||
{ # Check if Python is available (at `/data/python/octoprint`, set by PATH in Dockerfile)
|
||||
python --version
|
||||
} || { # Otherwise create Python virtual environment.
|
||||
python3 -m venv /data/python/octoprint
|
||||
# Install wheel to speed up future installs.
|
||||
pip install wheel
|
||||
}
|
||||
pip install octoprint==$OCTOPRINT_VERSION
|
||||
}
|
||||
|
||||
# Create initial OctoPrint config, if missing.
|
||||
if [ ! -f /data/config/octoprint/config.yaml ]; then
|
||||
mkdir -p /data/config/octoprint
|
||||
fi
|
||||
|
||||
# Update OctoPrint config with settings for the addon to behave properly.
|
||||
updateConfig()
|
||||
{
|
||||
# octoprint $BASEDIR config set --bool api.allowCrossOrigin true
|
||||
octoprint $BASEDIR config set folder.generated "/tmp/octoprint/generated"
|
||||
octoprint $BASEDIR config set folder.timelapse_tmp "/tmp/octoprint/timelapse/tmp"
|
||||
# octoprint $BASEDIR config set --bool server.allowFraming true
|
||||
octoprint $BASEDIR config set server.commands.serverRestartCommand "/scripts/octoprint_restart.sh"
|
||||
octoprint $BASEDIR config set server.commands.systemRestartCommand "/scripts/system_restart.sh"
|
||||
octoprint $BASEDIR config set server.commands.systemShutdownCommand "/scripts/system_shutdown.sh"
|
||||
octoprint $BASEDIR config set webcam.ffmpeg "/usr/bin/ffmpeg"
|
||||
}
|
||||
updateConfig
|
||||
|
||||
# Other setting changes, if needed. E.g. creating a user.
|
||||
# Update OctoPrint config with customized settings, not strictly required for addon to work but helps with features.
|
||||
# updateConfigCustom() {
|
||||
# Add user, if needed.
|
||||
# { # Make sure Ingress user for OctoPrint exists.
|
||||
# bashio::log.notice "Ensure Ingress user (homeassistant) exist."
|
||||
# if ! octoprint --basedir /data/config/octoprint user list | grep -q 'homeassistant'; then
|
||||
# new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo)
|
||||
# octoprint --basedir /data/config/octoprint user add --password "$new_password" --admin homeassistant # 2> /dev/null
|
||||
# fi
|
||||
# } || { # catch
|
||||
# bashio::log.warning "Failed to ensure Ingress user exists, may not be able to launch."
|
||||
# }
|
||||
# Trusted networks, access control etc.
|
||||
# }
|
||||
33
3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh
Normal file
33
3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Configures proxy
|
||||
# ==============================================================================
|
||||
|
||||
# Generate proxy configuration for internal and external access
|
||||
bashio::var.json \
|
||||
addon_hostname "$(bashio::addon.hostname)" \
|
||||
addon_ip "$(bashio::addon.ip_address)" \
|
||||
trusted_proxies "$(bashio::config 'trusted_proxies')" \
|
||||
| tempio \
|
||||
-template /usr/share/tempio/caddy/Caddyfile.internal_external.gtpl \
|
||||
-out /etc/caddy/sites-enabled/internal_external.caddy
|
||||
|
||||
# Generate proxy configuration for access by Ingress
|
||||
# bashio::var.json \
|
||||
# addon_hostname "$(bashio::addon.hostname)" \
|
||||
# addon_ip "$(bashio::addon.ip_address)" \
|
||||
# camera_host "$(bashio::config 'camera_url')" \
|
||||
# ingress_entry "$(bashio::addon.ingress_entry)" \
|
||||
# ingress_port "^$(bashio::addon.ingress_port)" \
|
||||
# interface "$(bashio::addon.ip_address)" \
|
||||
# mode "$(bashio::config 'mode')" \
|
||||
# supervisor_ip "$(bashio::supervisor.ip_address)" \
|
||||
# trusted_proxies "$(bashio::config 'trusted_proxies')" \
|
||||
# | tempio \
|
||||
# -template /usr/share/tempio/caddy/Caddyfile.ingress.gtpl \
|
||||
# -out /etc/caddy/sites-enabled/ingress.caddy
|
||||
|
||||
|
||||
# Make sure config is correctly formatted.
|
||||
caddy fmt --overwrite /etc/caddy/Caddyfile
|
||||
10
3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish
Normal file
10
3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Take down the S6 supervision tree when OctoPrint fails
|
||||
# ==============================================================================
|
||||
|
||||
# if -n { s6-test $# -ne 0 }
|
||||
# if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
# s6-svscanctl -t /var/run/s6/services
|
||||
10
3dprinter-octoprint/rootfs/etc/services.d/octoprint/run
Normal file
10
3dprinter-octoprint/rootfs/etc/services.d/octoprint/run
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Runs OctoPrint
|
||||
# ==============================================================================
|
||||
|
||||
bashio::log.info "Starting OctoPrint..."
|
||||
|
||||
## Run your program
|
||||
exec octoprint --basedir /data/config/octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 80
|
||||
5
3dprinter-octoprint/rootfs/etc/services.d/proxy/finish
Normal file
5
3dprinter-octoprint/rootfs/etc/services.d/proxy/finish
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Stop reverse proxy
|
||||
# ==============================================================================
|
||||
12
3dprinter-octoprint/rootfs/etc/services.d/proxy/run
Normal file
12
3dprinter-octoprint/rootfs/etc/services.d/proxy/run
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: 3dprinter-octoprint
|
||||
# Runs the reverse proxy.
|
||||
# ==============================================================================
|
||||
|
||||
# Wait for OctoPrint WebUI to be available
|
||||
bashio::net.wait_for 80
|
||||
|
||||
bashio::log.info "Starting proxy..."
|
||||
|
||||
exec caddy run --config /etc/caddy/Caddyfile --envfile /etc/caddy/env
|
||||
5
3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh
Normal file
5
3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.warning "Restart OctoPrint."
|
||||
|
||||
s6-svc -r /var/run/s6/legacy-services/octoprint
|
||||
5
3dprinter-octoprint/rootfs/scripts/proxy_restart.sh
Normal file
5
3dprinter-octoprint/rootfs/scripts/proxy_restart.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.warning "Restart proxy."
|
||||
|
||||
s6-svc -r /var/run/s6/legacy-services/proxy
|
||||
48
3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh
Normal file
48
3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh
Normal file
@ -0,0 +1,48 @@
|
||||
# #!/usr/bin/bash
|
||||
# # Set/update parts of OctoPrint config to work with addon.
|
||||
|
||||
# export OCTOPRINT_HOME=/data/config/octoprint
|
||||
|
||||
# # Access control
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json accessControl '
|
||||
# {
|
||||
# "localNetworks": [
|
||||
# "127.0.0.0/8",
|
||||
# "::1/128",
|
||||
# "172.30.32.2"
|
||||
# ]
|
||||
# }
|
||||
# '
|
||||
|
||||
# # API config
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json api '
|
||||
# {
|
||||
# "allowCrossOrigin": true
|
||||
# }
|
||||
# '
|
||||
|
||||
# # Folder config
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json folder '
|
||||
# {
|
||||
# "generated": "/tmp/octoprint/generated",
|
||||
# "timelapse_tmp": "/tmp/octoprint/timelapse/tmp"
|
||||
# }
|
||||
# '
|
||||
|
||||
# # Server config
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json server '
|
||||
# {
|
||||
# "allowFraming": true,
|
||||
# "commands": {
|
||||
# "serverRestartCommand": "/scripts/octoprint_restart.sh",
|
||||
# "systemRestartCommand": "/scripts/system_restart.sh",
|
||||
# "systemShutdownCommand": "/scripts/system_shutdown.sh"
|
||||
# }
|
||||
# }
|
||||
# '
|
||||
# # Webcam config
|
||||
# octoprint -b $OCTOPRINT_HOME config set --json webcam '
|
||||
# {
|
||||
# "ffmpeg": "/usr/bin/ffmpeg"
|
||||
# }
|
||||
# '
|
||||
5
3dprinter-octoprint/rootfs/scripts/system_restart.sh
Normal file
5
3dprinter-octoprint/rootfs/scripts/system_restart.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.warning "Restart addon."
|
||||
|
||||
bashio::addon.restart
|
||||
5
3dprinter-octoprint/rootfs/scripts/system_shutdown.sh
Normal file
5
3dprinter-octoprint/rootfs/scripts/system_shutdown.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
bashio::log.warning "Shutdown addon."
|
||||
|
||||
bashio::addon.stop
|
||||
@ -0,0 +1,46 @@
|
||||
:{{ .ingress_port }} {
|
||||
bind {{ .addon_ip }}
|
||||
@ingress {
|
||||
remote_ip {{ .supervisor_ip }}
|
||||
}
|
||||
uri strip_prefix {{ .ingress_entry }}
|
||||
handle {
|
||||
reverse_proxy @ingress 127.0.0.1:80/ {
|
||||
# header_up X-Script-Name {{ .ingress_entry }}
|
||||
# trusted_proxies {{ .supervisor_ip }}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# :8099 {
|
||||
# @ingress {
|
||||
# remote_ip {{ .supervisor_ip }}
|
||||
# }
|
||||
# uri strip_prefix {{ .ingress_entry }}
|
||||
#
|
||||
# handle_path /camera/* {
|
||||
# reverse_proxy @ingress {{ .camera_host }} {
|
||||
# }
|
||||
# }
|
||||
# handle {
|
||||
# {{ if eq .mode "camera" }}
|
||||
# reverse_proxy @ingress {{ .camera_host }} {
|
||||
# trusted_proxies 172.30.32.2
|
||||
# }
|
||||
# {{ else if eq .mode "recovery" }}
|
||||
# rewrite / /recovery
|
||||
# {{ else if eq .mode "reverse_proxy_test" }}
|
||||
# rewrite / /reverse_proxy_test
|
||||
# {{ end }}
|
||||
# reverse_proxy @ingress 127.0.0.1:80 {
|
||||
# header_up X-Script-Name {{ .ingress_entry }}
|
||||
# trusted_proxies 172.30.32.2
|
||||
# # header_up -Origin
|
||||
# # header_up Origin 172.30.32.2
|
||||
# # header_up X-Forwarded-For 172.30.32.2
|
||||
# # header_up X-Scheme {scheme}
|
||||
# # flush_interval -1
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
@ -0,0 +1,8 @@
|
||||
# Internal and external access. Used for:
|
||||
# * Home-Assistant OctoPrint integration.
|
||||
# * Accessing OctoPrint WebUI through external port.
|
||||
:5000 {
|
||||
reverse_proxy http://127.0.0.1:80 {
|
||||
trusted_proxies {{ .trusted_proxies }}
|
||||
}
|
||||
}
|
||||
21
README.md
Normal file
21
README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# 3dprinter-addons
|
||||
Addons for Home-Assistant, related to 3D printing.
|
||||
|
||||
## Install
|
||||
|
||||
You can use the following button to add the repository to your Home Assistant instance.
|
||||
|
||||
[](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Ffredrikbaberg%2F3dprinter-addons)
|
||||
|
||||
|
||||
## Addons
|
||||
|
||||
Not all addons are ready for use.
|
||||
|
||||
### 3DPrinter-OctoPrint
|
||||
|
||||
OctoPrint, plain and simple.
|
||||
|
||||
### Camera-mjpg-streamer
|
||||
|
||||
For streaming camera feed.
|
||||
32
camera-mjpg-streamer/DOCS.md
Normal file
32
camera-mjpg-streamer/DOCS.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Documentation
|
||||
|
||||
## Configuration
|
||||
|
||||
- `mjpg_input`: Specify input arguments for mjpg_streamer.
|
||||
|
||||
## How to use
|
||||
|
||||
Set input arguments through `mjpg_input` configuration option, start the add-on.
|
||||
|
||||
## Accessing camera from Home Assistant
|
||||
|
||||
The camera stream and snapshot can be accessed by e.g. [MJPEG IP Camera](https://www.home-assistant.io/integrations/mjpeg/), with URLs:
|
||||
* MJPEG URL: `http://<addon-hostname>/?action=stream`
|
||||
* Still image URL: `http://<addon-hostname>/?action=snapshot`.
|
||||
|
||||
Addon hostname can be found under [addon settings](https://my.home-assistant.io/redirect/supervisor_addon/?addon=b7aa59c4_camera-mjpg-streamer&repository_url=https%3A%2F%2Fgithub.com%2Ffredrikbaberg%2F3dprinter-addons).
|
||||
|
||||
## Tests
|
||||
|
||||
For testing you can set `mjpg_input` to:
|
||||
> input_file.so -f /www_mjpg -e
|
||||
|
||||
This will result in showing a test image.
|
||||
|
||||
## Versions
|
||||
|
||||
Some notes regarding the software and versions.
|
||||
Not all software is installed for all images.
|
||||
|
||||
- mjpg-streamer
|
||||
- Compiled from [https://github.com/jacksonliam/mjpg-streamer](https://github.com/jacksonliam/mjpg-streamer).
|
||||
23
camera-mjpg-streamer/Dockerfile
Normal file
23
camera-mjpg-streamer/Dockerfile
Normal file
@ -0,0 +1,23 @@
|
||||
ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base"
|
||||
|
||||
FROM ${BUILD_FROM} AS final
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
RUN echo "Install base requirements." \
|
||||
&& apk add --no-cache --virtual .necessary-mjpeg-streamer libjpeg nginx libgphoto2 \
|
||||
&& echo "Install mjpg-streamer." \
|
||||
&& apk add --no-cache --virtual .build-dependencies-mjpgstreamer make cmake build-base linux-headers libjpeg-turbo-dev libgphoto2-dev \
|
||||
&& wget -qO- https://github.com/jacksonliam/mjpg-streamer/archive/master.tar.gz | tar xz -C /tmp \
|
||||
&& cd /tmp/mjpg-streamer-master/mjpg-streamer-experimental/ \
|
||||
&& make --silent \
|
||||
&& make install --silent \
|
||||
&& mv www/ /www_mjpg \
|
||||
&& rm -rf /tmp/mjpg-streamer-master \
|
||||
&& apk del --no-cache .build-dependencies-mjpgstreamer
|
||||
COPY rootfs/ /
|
||||
WORKDIR /
|
||||
|
||||
# Make files executable
|
||||
RUN chmod +x /etc/cont-init.d/*.sh
|
||||
RUN chmod +x /etc/services.d/*/*
|
||||
5
camera-mjpg-streamer/README.md
Normal file
5
camera-mjpg-streamer/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# mjpg-streamer
|
||||
|
||||
Provides camera stream through `mjpg-streamer`, to be used by e.g. OctoPrint addon.
|
||||
|
||||
Instructions are provided in the tab "Docs".
|
||||
28
camera-mjpg-streamer/config.yaml
Normal file
28
camera-mjpg-streamer/config.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
name: "Camera-mjpg-streamer"
|
||||
version: "2022.7.0"
|
||||
slug: "camera-mjpg-streamer"
|
||||
description: "Camera streaming addon for Home Assistant, based on mjpg-streamer."
|
||||
url: "https://github.com/fredrikbaberg/3dprinter-addons/tree/main/camera-mjpg-streamer"
|
||||
ingress: true
|
||||
ingress_stream: true
|
||||
panel_icon: mdi:camera
|
||||
panel_title: mjpg-streamer
|
||||
arch:
|
||||
- armv7
|
||||
- amd64
|
||||
- armhf
|
||||
- aarch64
|
||||
- i386
|
||||
stage: experimental
|
||||
init: false
|
||||
video: true
|
||||
usb: true
|
||||
ports:
|
||||
80/tcp: null
|
||||
ports_description:
|
||||
80/tcp: Web-based interface (Not required for Ingress)
|
||||
options:
|
||||
mjpg_input: "input_uvc.so -n"
|
||||
schema:
|
||||
mjpg_input: "str"
|
||||
image: ghcr.io/fredrikbaberg/addon-camera-mjpg-streamer-{arch}
|
||||
22
camera-mjpg-streamer/rootfs/etc/cont-init.d/nginx.sh
Normal file
22
camera-mjpg-streamer/rootfs/etc/cont-init.d/nginx.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: aiortc
|
||||
# Configures NGINX for use with aiortc
|
||||
# ==============================================================================
|
||||
|
||||
# Generate Ingress configuration
|
||||
bashio::var.json \
|
||||
interface "$(bashio::addon.ip_address)" \
|
||||
port "^$(bashio::addon.ingress_port)" \
|
||||
| tempio \
|
||||
-template /etc/nginx/templates/ingress.gtpl \
|
||||
-out /etc/nginx/servers/ingress.conf
|
||||
|
||||
# Generate direct access configuration, if enabled.
|
||||
if bashio::var.has_value "$(bashio::addon.port 80)"; then
|
||||
bashio::var.json \
|
||||
port "^$(bashio::addon.port 80)" \
|
||||
| tempio \
|
||||
-template /etc/nginx/templates/direct.gtpl \
|
||||
-out /etc/nginx/servers/direct.conf
|
||||
fi
|
||||
96
camera-mjpg-streamer/rootfs/etc/nginx/includes/mime.types
Normal file
96
camera-mjpg-streamer/rootfs/etc/nginx/includes/mime.types
Normal 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;
|
||||
}
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -0,0 +1,8 @@
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers off;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
@ -0,0 +1,3 @@
|
||||
upstream backend {
|
||||
server 127.0.0.1:80;
|
||||
}
|
||||
44
camera-mjpg-streamer/rootfs/etc/nginx/nginx.conf
Normal file
44
camera-mjpg-streamer/rootfs/etc/nginx/nginx.conf
Normal file
@ -0,0 +1,44 @@
|
||||
# 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;
|
||||
|
||||
# Max num of simultaneous connections by a worker process.
|
||||
events {
|
||||
worker_connections 512;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/includes/mime.types;
|
||||
|
||||
access_log off;
|
||||
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/upstream.conf;
|
||||
include /etc/nginx/servers/*.conf;
|
||||
}
|
||||
10
camera-mjpg-streamer/rootfs/etc/nginx/templates/direct.gtpl
Normal file
10
camera-mjpg-streamer/rootfs/etc/nginx/templates/direct.gtpl
Normal file
@ -0,0 +1,10 @@
|
||||
server {
|
||||
listen {{ .port }} default_server;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
location / {
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
||||
13
camera-mjpg-streamer/rootfs/etc/nginx/templates/ingress.gtpl
Normal file
13
camera-mjpg-streamer/rootfs/etc/nginx/templates/ingress.gtpl
Normal file
@ -0,0 +1,13 @@
|
||||
server {
|
||||
listen {{ .interface }}:{{ .port }} default_server;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
location / {
|
||||
allow 172.30.32.2;
|
||||
deny all;
|
||||
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Add-on: mjpg-streamer
|
||||
# Take down the S6 supervision tree when mjpg-streamer fails
|
||||
# ==============================================================================
|
||||
if -n { s6-test $# -ne 0 }
|
||||
if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: mjpg-streamer
|
||||
# Runs mjpg-streamer
|
||||
# ==============================================================================
|
||||
|
||||
bashio::log.info "Starting mjpg-streamer.."
|
||||
|
||||
mjpg_streamer -i "$(bashio::config 'mjpg_input')" -o "output_http.so -w /www_mjpg -p 80"
|
||||
9
camera-mjpg-streamer/rootfs/etc/services.d/nginx/finish
Normal file
9
camera-mjpg-streamer/rootfs/etc/services.d/nginx/finish
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Add-on: mjpg-streamer
|
||||
# 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
|
||||
11
camera-mjpg-streamer/rootfs/etc/services.d/nginx/run
Normal file
11
camera-mjpg-streamer/rootfs/etc/services.d/nginx/run
Normal file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: mjpg-streamer
|
||||
# Runs the Nginx daemon
|
||||
# ==============================================================================
|
||||
|
||||
# Wait for aiortc web server to be available
|
||||
bashio::net.wait_for 80
|
||||
|
||||
bashio::log.info "Starting NGinx..."
|
||||
exec nginx
|
||||
4
camera-rtc/DOCS.md
Normal file
4
camera-rtc/DOCS.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Documentation
|
||||
|
||||
## Configuration
|
||||
|
||||
30
camera-rtc/Dockerfile
Normal file
30
camera-rtc/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
||||
ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye"
|
||||
FROM ${BUILD_FROM}
|
||||
|
||||
ENV PIP_FLAGS="--no-cache-dir"
|
||||
|
||||
# Install dependencies
|
||||
RUN apt update && \
|
||||
apt install -y \
|
||||
--no-install-recommends \
|
||||
python3-minimal \
|
||||
nginx \
|
||||
python3-pip \
|
||||
python3-dev \
|
||||
git \
|
||||
gcc \
|
||||
&& pip install ${PIP_FLAGS} aiohttp aiortc \
|
||||
&& git clone https://github.com/aiortc/aiortc \
|
||||
&& apt remove -y \
|
||||
python3-dev \
|
||||
git \
|
||||
gcc \
|
||||
&& apt -y autoremove \
|
||||
&& apt clean
|
||||
|
||||
# Copy root filesystem
|
||||
COPY rootfs /
|
||||
|
||||
# Make files executable
|
||||
RUN chmod +x /etc/cont-init.d/*.sh
|
||||
RUN chmod +x /etc/services.d/*/*
|
||||
5
camera-rtc/README.md
Normal file
5
camera-rtc/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Camera-RTC
|
||||
|
||||
**Note: This addon is broken and not ready for use.**
|
||||
|
||||
Camera addon with support for WebRTC.
|
||||
6
camera-rtc/build.yaml
Normal file
6
camera-rtc/build.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
build_from:
|
||||
aarch64: ghcr.io/home-assistant/aarch64-base-debian:bullseye
|
||||
amd64: ghcr.io/home-assistant/amd64-base-debian:bullseye
|
||||
armhf: ghcr.io/home-assistant/armhf-base-debian:bullseye
|
||||
armv7: ghcr.io/home-assistant/armv7-base-debian:bullseye
|
||||
i386: ghcr.io/home-assistant/i386-base-debian:bullseye
|
||||
22
camera-rtc/config.yaml
Normal file
22
camera-rtc/config.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
# name: "Camera-RTC"
|
||||
# version: "2022.7.012"
|
||||
# slug: "camera-aiortc"
|
||||
# description: "Camera stream with support for WebRTC."
|
||||
# url: "https://github.com/fredrikbaberg/3dprinter-addons/tree/main/camera-rtc"
|
||||
# ingress: true
|
||||
# ingress_stream: true
|
||||
# panel_icon: mdi:camera
|
||||
# arch:
|
||||
# - aarch64
|
||||
# - amd64
|
||||
# - armhf
|
||||
# - armv7
|
||||
# stage: experimental
|
||||
# init: false
|
||||
# video: true
|
||||
# usb: true
|
||||
# options:
|
||||
# webrtc_arguments: ''
|
||||
# schema:
|
||||
# webrtc_arguments: str
|
||||
# image: ghcr.io/fredrikbaberg/addon-camera-aiortc-{arch}
|
||||
13
camera-rtc/rootfs/etc/cont-init.d/nginx.sh
Normal file
13
camera-rtc/rootfs/etc/cont-init.d/nginx.sh
Normal file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: aiortc
|
||||
# Configures NGINX for use with aiortc
|
||||
# ==============================================================================
|
||||
|
||||
# Generate Ingress configuration
|
||||
bashio::var.json \
|
||||
interface "$(bashio::addon.ip_address)" \
|
||||
port "^$(bashio::addon.ingress_port)" \
|
||||
| tempio \
|
||||
-template /etc/nginx/templates/ingress.gtpl \
|
||||
-out /etc/nginx/servers/ingress.conf
|
||||
96
camera-rtc/rootfs/etc/nginx/includes/mime.types
Normal file
96
camera-rtc/rootfs/etc/nginx/includes/mime.types
Normal 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
camera-rtc/rootfs/etc/nginx/includes/proxy_params.conf
Normal file
15
camera-rtc/rootfs/etc/nginx/includes/proxy_params.conf
Normal 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;
|
||||
6
camera-rtc/rootfs/etc/nginx/includes/server_params.conf
Normal file
6
camera-rtc/rootfs/etc/nginx/includes/server_params.conf
Normal 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;
|
||||
8
camera-rtc/rootfs/etc/nginx/includes/ssl_params.conf
Normal file
8
camera-rtc/rootfs/etc/nginx/includes/ssl_params.conf
Normal file
@ -0,0 +1,8 @@
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers off;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
3
camera-rtc/rootfs/etc/nginx/includes/upstream.conf
Normal file
3
camera-rtc/rootfs/etc/nginx/includes/upstream.conf
Normal file
@ -0,0 +1,3 @@
|
||||
upstream backend {
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
44
camera-rtc/rootfs/etc/nginx/nginx.conf
Normal file
44
camera-rtc/rootfs/etc/nginx/nginx.conf
Normal file
@ -0,0 +1,44 @@
|
||||
# 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;
|
||||
|
||||
# Max num of simultaneous connections by a worker process.
|
||||
events {
|
||||
worker_connections 512;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/includes/mime.types;
|
||||
|
||||
access_log off;
|
||||
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/upstream.conf;
|
||||
include /etc/nginx/servers/*.conf;
|
||||
}
|
||||
0
camera-rtc/rootfs/etc/nginx/servers/.gitkeep
Normal file
0
camera-rtc/rootfs/etc/nginx/servers/.gitkeep
Normal file
21
camera-rtc/rootfs/etc/nginx/templates/direct.gtpl
Normal file
21
camera-rtc/rootfs/etc/nginx/templates/direct.gtpl
Normal file
@ -0,0 +1,21 @@
|
||||
server {
|
||||
{{ if not .ssl }}
|
||||
listen {{ .port }} default_server;
|
||||
{{ else }}
|
||||
listen {{ .port }} default_server ssl http2;
|
||||
{{ end }}
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
{{ if .ssl }}
|
||||
include /etc/nginx/includes/ssl_params.conf;
|
||||
|
||||
ssl_certificate /ssl/{{ .certfile }};
|
||||
ssl_certificate_key /ssl/{{ .keyfile }};
|
||||
{{ end }}
|
||||
|
||||
location / {
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
||||
13
camera-rtc/rootfs/etc/nginx/templates/ingress.gtpl
Normal file
13
camera-rtc/rootfs/etc/nginx/templates/ingress.gtpl
Normal file
@ -0,0 +1,13 @@
|
||||
server {
|
||||
listen {{ .interface }}:{{ .port }} default_server;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
location / {
|
||||
allow 172.30.32.2;
|
||||
deny all;
|
||||
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
||||
9
camera-rtc/rootfs/etc/services.d/aiortc/finish
Normal file
9
camera-rtc/rootfs/etc/services.d/aiortc/finish
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Add-on: aiortc
|
||||
# Take down the S6 supervision tree when aiortc fails
|
||||
# ==============================================================================
|
||||
if -n { s6-test $# -ne 0 }
|
||||
if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
15
camera-rtc/rootfs/etc/services.d/aiortc/run
Normal file
15
camera-rtc/rootfs/etc/services.d/aiortc/run
Normal file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: aiortc
|
||||
# Runs aiortc
|
||||
# ==============================================================================
|
||||
declare -a options
|
||||
|
||||
if bashio::config.has_value 'webrtc_arguments'; then
|
||||
options+="$(bashio::config 'webrtc_arguments')"
|
||||
fi
|
||||
|
||||
bashio::log.info "Starting aiortc..."
|
||||
|
||||
# Run aiortc
|
||||
exec python3 /aiortc/examples/webcam/webcam.py "${options[@]}"
|
||||
9
camera-rtc/rootfs/etc/services.d/nginx/finish
Normal file
9
camera-rtc/rootfs/etc/services.d/nginx/finish
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Add-on: aiortc
|
||||
# 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
|
||||
11
camera-rtc/rootfs/etc/services.d/nginx/run
Normal file
11
camera-rtc/rootfs/etc/services.d/nginx/run
Normal file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Add-on: aiortc
|
||||
# Runs the Nginx daemon
|
||||
# ==============================================================================
|
||||
|
||||
# Wait for aiortc web server to be available
|
||||
bashio::net.wait_for 8080
|
||||
|
||||
bashio::log.info "Starting NGinx..."
|
||||
exec nginx
|
||||
3
repository.yaml
Normal file
3
repository.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
name: fredrikbaberg 3DPrinter addons for Home-Asssistant
|
||||
url: https://github.com/fredrikbaberg/3dprinter-addons
|
||||
maintainer: Fredrik Baberg <fredrik.baberg@gmail.com>
|
||||
Loading…
Reference in New Issue
Block a user