From 870a831e2efa36db1cd5b41aa9a84a19d6c19c1a Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sat, 5 Nov 2022 16:24:05 +0100 Subject: [PATCH] Update to OctoPrint, 2022.11.01. --- 3dprinter-octoprint/CHANGELOG.md | 6 ++++++ 3dprinter-octoprint/DOCS.md | 16 ++++++++++++++-- 3dprinter-octoprint/README.md | 4 ++-- 3dprinter-octoprint/config.yaml | 4 ++-- .../rootfs/etc/cont-init.d/octoprint.sh | 9 +++++---- .../rootfs/usr/share/tempio/Caddyfile.gtpl | 6 ++++++ 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/3dprinter-octoprint/CHANGELOG.md b/3dprinter-octoprint/CHANGELOG.md index 01084fc..f300d70 100644 --- a/3dprinter-octoprint/CHANGELOG.md +++ b/3dprinter-octoprint/CHANGELOG.md @@ -1,3 +1,9 @@ +- 2022.11.01 + - Add reverse proxy config for camera with Ingress (untested). + - Only create OctoPrint user if missing. + - Update documentation. + - Mark mode optional. + - Update OctoPrint to 1.8.6 - Update icon to coloured nozzle. - Clean-up Caddy config. diff --git a/3dprinter-octoprint/DOCS.md b/3dprinter-octoprint/DOCS.md index ef72f39..00adea1 100644 --- a/3dprinter-octoprint/DOCS.md +++ b/3dprinter-octoprint/DOCS.md @@ -1,3 +1,15 @@ -# Dev -> image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} +# Addon configuration +## Camera URL + +**Note: Currently not working.** + +Through setting a camera URL you should be able to access the camera stream even when using Ingress. + +## Mode + +By specifying a different mode you can instead access recovery and reverse proy test page. Normally this should not be needed. + +# Notes etc. + +> image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} diff --git a/3dprinter-octoprint/README.md b/3dprinter-octoprint/README.md index e5dcc29..4529770 100644 --- a/3dprinter-octoprint/README.md +++ b/3dprinter-octoprint/README.md @@ -1,5 +1,5 @@ # 3DPrinter-OctoPrint -Provides OctoPrint as an addon to Home Assistant. +**Note: Currently not in a ready-to-use state.** -**Note: Currently not in a ready-to-use state.** \ No newline at end of file +Provides OctoPrint as an addon to Home Assistant. diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index bfde696..ca969bc 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.11.0" +version: "2022.11.01" 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" @@ -28,5 +28,5 @@ options: mode: normal schema: camera_url: "url?" - mode: "list(normal|recovery|reverse_proxy_test)" + mode: "list(normal|recovery|reverse_proxy_test)?" tmpfs: true diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index f2ed904..b381d11 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -28,12 +28,13 @@ if [ ! -f /data/config/octoprint/config.yaml ]; then fi fi -# TODO: Check if user already exists before setting password. { # Make sure Ingress user for OctoPrint exists. bashio::log.notice "Ensure Ingress user (homeassistant) exist." - new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo) - new_password=homeassistant - octoprint --basedir /data/config/octoprint user add homeassistant --password "$new_password" --group users --group admins # 2> /dev/null + if ! octoprint --basedir /data/config/octoprint user list | grep -q 'homeassistant'; then + new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo) + new_password=homeassistant + 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." } diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index 7a9b521..73a9340 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -11,6 +11,12 @@ remote_ip 172.30.32.2 } uri strip_prefix {{ .ingress_entry }} + + handle_path /camera/* { + reverse_proxy @ingress {{ .camera_host }} { + } + } + handle { {{ if eq .mode "recovery" }} rewrite / /recovery