From 1da9097b38b6b43766ab1eacb42144b901d67adb Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Wed, 11 Jan 2023 18:03:48 +0100 Subject: [PATCH] Gone through the files to prepare for release. --- 3dprinter-octoprint/CHANGELOG.md | 35 ++------ 3dprinter-octoprint/DOCS.md | 24 ++++-- 3dprinter-octoprint/README.md | 1 + 3dprinter-octoprint/build.yaml | 2 +- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/caddy/Caddyfile | 2 +- .../rootfs/etc/cont-init.d/octoprint.sh | 23 ++--- .../rootfs/etc/services.d/octoprint/finish | 2 +- .../rootfs/root/config/octoprint/config.yaml | 20 ----- .../rootfs/scripts/set_octoprint_config.sh | 86 +++++++++---------- 10 files changed, 81 insertions(+), 116 deletions(-) delete mode 100644 3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml diff --git a/3dprinter-octoprint/CHANGELOG.md b/3dprinter-octoprint/CHANGELOG.md index 179660d..a9fbfe0 100644 --- a/3dprinter-octoprint/CHANGELOG.md +++ b/3dprinter-octoprint/CHANGELOG.md @@ -1,28 +1,7 @@ -- 2022.12.05 - - Revert to OctoPrint 1.7.3. - - Bugfix to options. - -- 2022.12.04 - - Correction to name of option (trusted_proxies). - -- 2022.12.03 - - Add option for trusted proxies. - -- 2022.12.02 - - Use image instead of local build. - -- 2022.12.01 - - Add mode for camera (for testing). - - Set Caddy to trust private ranges on Ingress entry. - -- 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. -- Fixes to Caddy XDG paths -- Change reverse proxy from nginx to Caddy \ No newline at end of file +## 2023.01.0 + * Disabled Ingress + * Default config now set by API instead of copying a file (should make it more flexible). + * Using Caddy as reverse proxy. + * Added option to set trusted_proxies, should help with reverse proxy configuration. + * Updated to OctoPrint 1.8.6. + * Based on Debian instead of Alpine, should make more plugins compatible. diff --git a/3dprinter-octoprint/DOCS.md b/3dprinter-octoprint/DOCS.md index 8d96253..c5568c7 100644 --- a/3dprinter-octoprint/DOCS.md +++ b/3dprinter-octoprint/DOCS.md @@ -1,15 +1,25 @@ # Addon configuration -## Mode +## Trusted proxies -By specifying a different mode you can instead access recovery and reverse proy test page. Normally this should not be needed. +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). -# Notes etc. +# Camera -> image: ghcr.io/fredrikbaberg/ha-addon-3dprinter-octoprint-{arch} +There is no camera server in the addon, it has to be setup separately. -## Camera URL +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: Currently not used.** +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. -Through setting a camera URL you should be able to access the camera stream even when using Ingress. +# 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. diff --git a/3dprinter-octoprint/README.md b/3dprinter-octoprint/README.md index a7a2b96..eef92df 100644 --- a/3dprinter-octoprint/README.md +++ b/3dprinter-octoprint/README.md @@ -3,3 +3,4 @@ Provides OctoPrint as an addon to Home Assistant. Note: Ingress is **NOT** supported. + diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 28f6dc1..b9d2fcc 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -9,4 +9,4 @@ labels: 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" + OCTOPRINT_VERSION: "1.7.3" diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 971aec1..5d95181 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2023.01.04" +version: "2023.01.05" 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" diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index 08e5e2c..deaf315 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -1,5 +1,5 @@ { - debug + # debug log { format console output file /var/log/caddy/caddy.log diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index 8269e3f..bf03afd 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -8,7 +8,7 @@ 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`, according to PATH) + { # 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 @@ -18,9 +18,13 @@ export BASEDIR="--basedir /data/config/octoprint" 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 required for the addon to work properly (should be OK to run each time). -updateRequiredConfig() +# 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" @@ -31,7 +35,9 @@ updateRequiredConfig() 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. @@ -46,14 +52,3 @@ updateRequiredConfig() # } # Trusted networks, access control etc. # } - - -# Create initial OctoPrint config, if missing. -if [ ! -f /data/config/octoprint/config.yaml ]; then - mkdir -p /data/config/octoprint -fi - -# Update required config for running OctoPrint properly in addon. -updateRequiredConfig - -# Make sure users exists, if needed. diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish index 4595fc3..ff80240 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish @@ -6,5 +6,5 @@ # if -n { s6-test $# -ne 0 } # if -n { s6-test ${1} -eq 256 } -# + # s6-svscanctl -t /var/run/s6/services diff --git a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml deleted file mode 100644 index 0280ecd..0000000 --- a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# accessControl: -# autologinAs: homeassistant -# autologinLocal: true -# localNetworks: -# - 127.0.0.0/8 -# - ::1/128 -# - 172.30.32.2 -api: - allowCrossOrigin: true -folder: - generated: /tmp/octoprint/generated - timelapse_tmp: /tmp/octoprint/timelapse/tmp -server: - allowFraming: true - commands: - serverRestartCommand: /scripts/octoprint_restart.sh - systemRestartCommand: /scripts/system_restart.sh - systemShutdownCommand: /scripts/system_shutdown.sh -webcam: - ffmpeg: /usr/bin/ffmpeg diff --git a/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh b/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh index de539a2..cd6e54b 100644 --- a/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh +++ b/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh @@ -1,48 +1,48 @@ -#!/usr/bin/bash -# Set/update parts of OctoPrint config to work with addon. +# #!/usr/bin/bash +# # Set/update parts of OctoPrint config to work with addon. -export OCTOPRINT_HOME=/data/config/octoprint +# 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" - ] -} -' +# # 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 -} -' +# # 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" -} -' +# # 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" -} -' \ No newline at end of file +# # 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" +# } +# ' \ No newline at end of file