diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..5d7a6b0 --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,36 @@ +{ + "name": "Example devcontainer for add-on repositories", + "image": "ghcr.io/home-assistant/devcontainer:addons", + "appPort": [ + "7123:8123", + "7357:4357" + ], + "postStartCommand": "sudo -E 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 + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..f426c2c --- /dev/null +++ b/.vscode/tasks.json @@ -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": [] + } + ] +} diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 28f6dc1..e2ceeb3 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.8.2" diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index cb1620e..3911823 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -28,12 +28,12 @@ if [ ! -f /data/config/octoprint/config.yaml ]; then fi fi -{ # 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." -} +# { # 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." +# } diff --git a/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh b/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh new file mode 100644 index 0000000..de539a2 --- /dev/null +++ b/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh @@ -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" +} +' \ No newline at end of file