diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index f0933de..a594455 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,74 +1,74 @@ ---- -# yamllint disable rule:line-length -name: Bug Report Form -description: Report an issue with an add-on. -body: - - type: markdown - attributes: - value: | - This issue form is for reporting bugs. - - - type: textarea - validations: - required: true - attributes: - label: Describe the issue you are experiencing - description: Provide a clear and concise description of what the bug is. - - - type: markdown - attributes: - value: | - ## Environment - - - type: dropdown - validations: - required: true - attributes: - label: Which add-on are you reporting an issue with? - options: - - 3DPrinter-OctoPrint - - 3DPrinter-Remote - - Camera-mjpg-streamer - - - type: input - validations: - required: true - attributes: - label: What is the version of the add-on? - - - type: markdown - attributes: - value: | - # Details - - - type: textarea - validations: - required: false - attributes: - label: Steps to reproduce the issue - description: | - Please tell us exactly how to reproduce your issue. - Provide clear and concise step by step instructions and add code snippets if needed. - value: | - 1. - 2. - 3. - ... - - - type: textarea - attributes: - label: Anything in the add-on logs that might be useful? - description: > - Addon Logs can be found in [Settings -> System -> Logs](https://my.home-assistant.io/redirect/logs/) - then choose the add-on in the top right. - - [![Open your Home Assistant instance and show your Home Assistant logs.](https://my.home-assistant.io/badges/logs.svg)](https://my.home-assistant.io/redirect/logs/) - render: txt - - - type: textarea - attributes: - label: Additional information - description: > - If you have any additional information for us, use the field below. - Please note, you can attach screenshots or screen recordings here, by - dragging and dropping files in the field below. +--- +# yamllint disable rule:line-length +name: Bug Report Form +description: Report an issue with an add-on. +body: + - type: markdown + attributes: + value: | + This issue form is for reporting bugs. + + - type: textarea + validations: + required: true + attributes: + label: Describe the issue you are experiencing + description: Provide a clear and concise description of what the bug is. + + - type: markdown + attributes: + value: | + ## Environment + + - type: dropdown + validations: + required: true + attributes: + label: Which add-on are you reporting an issue with? + options: + - 3DPrinter-OctoPrint + - 3DPrinter-Remote + - Camera-mjpg-streamer + + - type: input + validations: + required: true + attributes: + label: What is the version of the add-on? + + - type: markdown + attributes: + value: | + # Details + + - type: textarea + validations: + required: false + attributes: + label: Steps to reproduce the issue + description: | + Please tell us exactly how to reproduce your issue. + Provide clear and concise step by step instructions and add code snippets if needed. + value: | + 1. + 2. + 3. + ... + + - type: textarea + attributes: + label: Anything in the add-on logs that might be useful? + description: > + Addon Logs can be found in [Settings -> System -> Logs](https://my.home-assistant.io/redirect/logs/) + then choose the add-on in the top right. + + [![Open your Home Assistant instance and show your Home Assistant logs.](https://my.home-assistant.io/badges/logs.svg)](https://my.home-assistant.io/redirect/logs/) + render: txt + + - type: textarea + attributes: + label: Additional information + description: > + If you have any additional information for us, use the field below. + Please note, you can attach screenshots or screen recordings here, by + dragging and dropping files in the field below. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index a415904..4737465 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,32 +1,32 @@ ---- -# yamllint disable rule:line-length -name: Feature Request Form -description: Make a feature request / suggestion. -body: - - type: markdown - attributes: - value: | - This form is for asking for feature requests. - - - type: dropdown - validations: - required: true - attributes: - label: If this relates to an existing add-on, please select which one. - options: - - Other - - 3DPrinter-OctoPrint - - 3DPrinter-Remote - - Camera-mjpg-streamer - - - type: textarea - validations: - required: true - attributes: - label: What feature would you like to be added? - description: Provide a clear and concise description of what you would like to have added. - - - type: markdown - attributes: - value: | - ## Environment +--- +# yamllint disable rule:line-length +name: Feature Request Form +description: Make a feature request / suggestion. +body: + - type: markdown + attributes: + value: | + This form is for asking for feature requests. + + - type: dropdown + validations: + required: true + attributes: + label: If this relates to an existing add-on, please select which one. + options: + - Other + - 3DPrinter-OctoPrint + - 3DPrinter-Remote + - Camera-mjpg-streamer + + - type: textarea + validations: + required: true + attributes: + label: What feature would you like to be added? + description: Provide a clear and concise description of what you would like to have added. + + - type: markdown + attributes: + value: | + ## Environment diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 90e05c4..c44e826 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,11 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - package-ecosystem: "github-actions" # See documentation for possible values - directory: "/" # Location of package manifests - schedule: - interval: "weekly" +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a3df5c..276376e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,119 +1,119 @@ ---- -# yamllint disable rule:line-length rule:truthy -name: Build add-on(s) - -env: - BUILD_ARGS: "--test" - MONITORED_FILES: "apparmor.txt build.yaml config.yaml Dockerfile rootfs" - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - init: - runs-on: ubuntu-latest - name: Initialize builds - outputs: - changed_addons: ${{ steps.changed_addons.outputs.addons }} - changed: ${{ steps.changed_addons.outputs.changed }} - steps: - - name: Check out the repository - uses: actions/checkout@v4 - - - name: Get changed files - id: changed_files - # uses: jitterbit/get-changed-files@v1 - uses: masesgroup/retrieve-changed-files@v3 - with: - format: 'space-delimited' - - - name: Find add-on directories - id: addons - uses: home-assistant/actions/helpers/find-addons@master - - - name: Get changed add-ons - id: changed_addons - run: | - declare -a changed_addons - for addon in ${{ steps.addons.outputs.addons }}; do - if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then - for file in ${{ env.MONITORED_FILES }}; do - if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then - if [[ ! "${changed_addons[@]}" =~ $addon ]]; then - changed_addons+=("\"${addon}\","); - fi - fi - done - fi - done - - changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev) - - if [[ -n ${changed} ]]; then - echo "Changed add-ons: $changed"; - echo "changed=true" >> "$GITHUB_OUTPUT"; - echo "addons=[$changed]" >> "$GITHUB_OUTPUT"; - else - echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})"; - fi - - build: - needs: init - runs-on: ubuntu-latest - if: needs.init.outputs.changed == 'true' - name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on - strategy: - matrix: - addon: ${{ fromJson(needs.init.outputs.changed_addons) }} - arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] - - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - 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 "build_arch=true" >> "$GITHUB_OUTPUT"; - else - echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"; - fi - - - name: Set build arguments - if: steps.check.outputs.build_arch == 'true' - run: | - if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then - echo "BUILD_ARGS=--docker-hub-check" >> $GITHUB_ENV; - fi - - - name: Login to GitHub Container Registry - if: env.BUILD_ARGS != '--test' - uses: docker/login-action@v3.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@2024.01.0 - with: - args: | - ${{ env.BUILD_ARGS }} \ - --${{ matrix.arch }} \ - --target /data/${{ matrix.addon }} \ - --image "${{ steps.check.outputs.image }}" \ - --docker-hub "ghcr.io/${{ github.repository_owner }}" \ - --addon +--- +# yamllint disable rule:line-length rule:truthy +name: Build add-on(s) + +env: + BUILD_ARGS: "--test" + MONITORED_FILES: "apparmor.txt build.yaml config.yaml Dockerfile rootfs" + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + init: + runs-on: ubuntu-latest + name: Initialize builds + outputs: + changed_addons: ${{ steps.changed_addons.outputs.addons }} + changed: ${{ steps.changed_addons.outputs.changed }} + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Get changed files + id: changed_files + # uses: jitterbit/get-changed-files@v1 + uses: masesgroup/retrieve-changed-files@v3 + with: + format: 'space-delimited' + + - name: Find add-on directories + id: addons + uses: home-assistant/actions/helpers/find-addons@master + + - name: Get changed add-ons + id: changed_addons + run: | + declare -a changed_addons + for addon in ${{ steps.addons.outputs.addons }}; do + if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then + for file in ${{ env.MONITORED_FILES }}; do + if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then + if [[ ! "${changed_addons[@]}" =~ $addon ]]; then + changed_addons+=("\"${addon}\","); + fi + fi + done + fi + done + + changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev) + + if [[ -n ${changed} ]]; then + echo "Changed add-ons: $changed"; + echo "changed=true" >> "$GITHUB_OUTPUT"; + echo "addons=[$changed]" >> "$GITHUB_OUTPUT"; + else + echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})"; + fi + + build: + needs: init + runs-on: ubuntu-latest + if: needs.init.outputs.changed == 'true' + name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on + strategy: + matrix: + addon: ${{ fromJson(needs.init.outputs.changed_addons) }} + arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - 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 "build_arch=true" >> "$GITHUB_OUTPUT"; + else + echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"; + fi + + - name: Set build arguments + if: steps.check.outputs.build_arch == 'true' + run: | + if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then + echo "BUILD_ARGS=--docker-hub-check" >> $GITHUB_ENV; + fi + + - name: Login to GitHub Container Registry + if: env.BUILD_ARGS != '--test' + uses: docker/login-action@v3.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@2024.01.0 + with: + args: | + ${{ env.BUILD_ARGS }} \ + --${{ matrix.arch }} \ + --target /data/${{ matrix.addon }} \ + --image "${{ steps.check.outputs.image }}" \ + --docker-hub "ghcr.io/${{ github.repository_owner }}" \ + --addon diff --git a/.github/workflows/cleanup-packages.yml b/.github/workflows/cleanup-packages.yml index fbf9b0e..7fae070 100644 --- a/.github/workflows/cleanup-packages.yml +++ b/.github/workflows/cleanup-packages.yml @@ -1,28 +1,28 @@ -name: cleanup-packages - -on: - workflow_dispatch: - -jobs: - cleanup: - runs-on: ubuntu-latest - name: Cleanup packages - steps: - - name: Delete RC version of packages - uses: smartsquaregmbh/delete-old-packages@v0.7.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - user: fredrikbaberg - type: container - version-pattern: "^\\d+\\.\\d+\\.\\d+-RC\\d+$" # The regex needs to be escaped! - keep: 2 - names: | - ha-addon-3dprinter-octoprint-aarch64 - ha-addon-3dprinter-octoprint-amd64 - ha-addon-3dprinter-octoprint-armhf - ha-addon-3dprinter-octoprint-armv7 - ha-addon-camera-mjpg-streamer-aarch64 - ha-addon-camera-mjpg-streamer-amd64 - ha-addon-camera-mjpg-streamer-armhf - ha-addon-camera-mjpg-streamer-armv7 - ha-addon-camera-mjpg-streamer-i386 +name: cleanup-packages + +on: + workflow_dispatch: + +jobs: + cleanup: + runs-on: ubuntu-latest + name: Cleanup packages + steps: + - name: Delete RC version of packages + uses: smartsquaregmbh/delete-old-packages@v0.7.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + user: fredrikbaberg + type: container + version-pattern: "^\\d+\\.\\d+\\.\\d+-RC\\d+$" # The regex needs to be escaped! + keep: 2 + names: | + ha-addon-3dprinter-octoprint-aarch64 + ha-addon-3dprinter-octoprint-amd64 + ha-addon-3dprinter-octoprint-armhf + ha-addon-3dprinter-octoprint-armv7 + ha-addon-camera-mjpg-streamer-aarch64 + ha-addon-camera-mjpg-streamer-amd64 + ha-addon-camera-mjpg-streamer-armhf + ha-addon-camera-mjpg-streamer-armv7 + ha-addon-camera-mjpg-streamer-i386 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9a8891f..10f3a91 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,41 +1,41 @@ -name: Lint - -on: - push: - branches: - - main - pull_request: - branches: - - main - schedule: - - cron: "0 0 * * *" - -jobs: - find: - name: Find add-ons - runs-on: ubuntu-latest - outputs: - addons: ${{ steps.addons.outputs.addons_list }} - steps: - - name: ⤵️ Check out code from GitHub - uses: actions/checkout@v4 - - - name: 🔍 Find add-on directories - id: addons - uses: home-assistant/actions/helpers/find-addons@master - - lint: - name: Lint add-on ${{ matrix.path }} - runs-on: ubuntu-latest - needs: find - strategy: - matrix: - path: ${{ fromJson(needs.find.outputs.addons) }} - steps: - - name: ⤵️ Check out code from GitHub - uses: actions/checkout@v4 - - - name: 🚀 Run Home Assistant Add-on Lint - uses: frenck/action-addon-linter@v2.15 - with: - path: "./${{ matrix.path }}" +name: Lint + +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: "0 0 * * *" + +jobs: + find: + name: Find add-ons + runs-on: ubuntu-latest + outputs: + addons: ${{ steps.addons.outputs.addons_list }} + steps: + - name: ⤵️ Check out code from GitHub + uses: actions/checkout@v4 + + - name: 🔍 Find add-on directories + id: addons + uses: home-assistant/actions/helpers/find-addons@master + + lint: + name: Lint add-on ${{ matrix.path }} + runs-on: ubuntu-latest + needs: find + strategy: + matrix: + path: ${{ fromJson(needs.find.outputs.addons) }} + steps: + - name: ⤵️ Check out code from GitHub + uses: actions/checkout@v4 + + - name: 🚀 Run Home Assistant Add-on Lint + uses: frenck/action-addon-linter@v2.15 + with: + path: "./${{ matrix.path }}" diff --git a/.github/workflows/manual-build-3dprinter-octoprint.yml b/.github/workflows/manual-build-3dprinter-octoprint.yml index 377313e..4cdb1b9 100644 --- a/.github/workflows/manual-build-3dprinter-octoprint.yml +++ b/.github/workflows/manual-build-3dprinter-octoprint.yml @@ -1,54 +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@v4 - - - 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@v3.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@2024.01.0 - 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 +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@v4 + + - 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@v3.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@2024.01.0 + 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 diff --git a/.github/workflows/manual-build-3dprinter-remote.yml b/.github/workflows/manual-build-3dprinter-remote.yml index e3b9bca..0b00ea3 100644 --- a/.github/workflows/manual-build-3dprinter-remote.yml +++ b/.github/workflows/manual-build-3dprinter-remote.yml @@ -1,54 +1,54 @@ -name: 3DPrinter-Remote - manual build - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on - strategy: - matrix: - addon: ["3dprinter-remote"] - arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] - steps: - - name: Check out the repository - uses: actions/checkout@v4 - - - 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@v3.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@2024.01.0 - 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 +name: 3DPrinter-Remote - manual build + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on + strategy: + matrix: + addon: ["3dprinter-remote"] + arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - 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@v3.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@2024.01.0 + 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 diff --git a/.github/workflows/manual-build-camera-mjpg-streamer.yml b/.github/workflows/manual-build-camera-mjpg-streamer.yml index 8901119..7edd5fc 100644 --- a/.github/workflows/manual-build-camera-mjpg-streamer.yml +++ b/.github/workflows/manual-build-camera-mjpg-streamer.yml @@ -1,54 +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@v4 - - - 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@v3.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@2024.01.0 - 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 +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@v4 + + - 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@v3.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@2024.01.0 + 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 diff --git a/.github/workflows/manual-build-camera-ustreamer.yml b/.github/workflows/manual-build-camera-ustreamer.yml index 1653e22..38acfa1 100644 --- a/.github/workflows/manual-build-camera-ustreamer.yml +++ b/.github/workflows/manual-build-camera-ustreamer.yml @@ -1,54 +1,54 @@ -name: camera-ustreamer - manual build - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on - strategy: - matrix: - addon: ["camera-ustreamer"] - arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] - steps: - - name: Check out the repository - uses: actions/checkout@v4 - - - 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@v3.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@2024.01.0 - 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 +name: camera-ustreamer - manual build + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on + strategy: + matrix: + addon: ["camera-ustreamer"] + arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - 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@v3.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@2024.01.0 + 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 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 4d4f276..84acfa8 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,27 +1,27 @@ ---- -# yamllint disable rule:truthy -name: Stale - -on: - schedule: - - cron: "0 * * * *" - workflow_dispatch: - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - name: 30 days stale issues - uses: actions/stale@v9.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-issue-stale: 30 - days-before-issue-close: 7 - operations-per-run: 150 - remove-stale-when-updated: true - stale-issue-label: "stale" - exempt-issue-labels: "pinned,security,Help wanted" - stale-issue-message: > - This issue has been automatically marked as stale because it has - not had recent activity. It will be closed if no further activity +--- +# yamllint disable rule:truthy +name: Stale + +on: + schedule: + - cron: "0 * * * *" + workflow_dispatch: + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - name: 30 days stale issues + uses: actions/stale@v9.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-issue-stale: 30 + days-before-issue-close: 7 + operations-per-run: 150 + remove-stale-when-updated: true + stale-issue-label: "stale" + exempt-issue-labels: "pinned,security,Help wanted" + stale-issue-message: > + This issue has been automatically marked as stale because it has + not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index eb56df2..118362a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,10 @@ -{ - "spellright.language": [ - "en" - ], - "spellright.documentTypes": [ - "markdown", - "latex", - "plaintext" - ] +{ + "spellright.language": [ + "en" + ], + "spellright.documentTypes": [ + "markdown", + "latex", + "plaintext" + ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6f51015..ee1c507 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,19 +1,19 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Start Home Assistant", - "type": "shell", - "command": "supervisor_run", - "group": { - "kind": "test", - "isDefault": true - }, - "presentation": { - "reveal": "always", - "panel": "new" - }, - "problemMatcher": [] - } - ] +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Start Home Assistant", + "type": "shell", + "command": "supervisor_run", + "group": { + "kind": "test", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + } + ] } \ No newline at end of file diff --git a/3dprinter-klipper/CHANGELOG.md b/3dprinter-klipper/CHANGELOG.md index 01c2ef3..bb4b87f 100644 --- a/3dprinter-klipper/CHANGELOG.md +++ b/3dprinter-klipper/CHANGELOG.md @@ -1,2 +1,2 @@ -## 2024.02.0 - * Initial version +## 2024.02.0 + * Initial version diff --git a/3dprinter-klipper/Dockerfile b/3dprinter-klipper/Dockerfile index 45768d8..81d1fdb 100644 --- a/3dprinter-klipper/Dockerfile +++ b/3dprinter-klipper/Dockerfile @@ -1,38 +1,38 @@ -ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base" -FROM ${BUILD_FROM} - -# Setup path for persistent install of Python packages -ENV ADDON_CONFIG_PATH=/config -ENV ADDON_SRC_PATH=/config/src -ENV ADDON_VENV_PATH=/config/python - - -# Install required packages -RUN apk add -U \ - # Proxy - caddy \ - # Common - git \ - py3-virtualenv \ - iproute2 \ - # Klipper - libffi-dev \ - gcc \ - g++ \ - python3-dev \ - make \ - # AVR chip installation and building - avrdude gcc-avr binutils-avr avr-libc \ - # ARM chip installation and building - gcc-arm-none-eabi binutils-arm-none-eabi newlib-arm-none-eabi \ - stm32flash \ - # Moonraker - libsodium-dev \ - patch \ - # Simulavr - cmake swig \ - # Fluidd - wget unzip - -# Copy root filesystem -COPY rootfs / +ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base" +FROM ${BUILD_FROM} + +# Setup path for persistent install of Python packages +ENV ADDON_CONFIG_PATH=/config +ENV ADDON_SRC_PATH=/config/src +ENV ADDON_VENV_PATH=/config/python + + +# Install required packages +RUN apk add -U \ + # Proxy + caddy \ + # Common + git \ + py3-virtualenv \ + iproute2 \ + # Klipper + libffi-dev \ + gcc \ + g++ \ + python3-dev \ + make \ + # AVR chip installation and building + avrdude gcc-avr binutils-avr avr-libc \ + # ARM chip installation and building + gcc-arm-none-eabi binutils-arm-none-eabi newlib-arm-none-eabi \ + stm32flash \ + # Moonraker + libsodium-dev \ + patch \ + # Simulavr + cmake swig \ + # Fluidd + wget unzip + +# Copy root filesystem +COPY rootfs / diff --git a/3dprinter-klipper/README.md b/3dprinter-klipper/README.md index cd7fd35..47a7dd2 100644 --- a/3dprinter-klipper/README.md +++ b/3dprinter-klipper/README.md @@ -1,3 +1,3 @@ -# 3DPrinter-Klipper - -Provides Klipper as an addon to Home Assistant. +# 3DPrinter-Klipper + +Provides Klipper as an addon to Home Assistant. diff --git a/3dprinter-klipper/config.yaml b/3dprinter-klipper/config.yaml index eaca0f9..8054639 100644 --- a/3dprinter-klipper/config.yaml +++ b/3dprinter-klipper/config.yaml @@ -1,33 +1,33 @@ -name: "3DPrinter-Klipper" -version: "2024.2.0" -slug: "3dprinter-klipper" -description: "Klipper with Moonraker and frontend(s) as an addon." -arch: - - armv7 - - amd64 - - armhf - - aarch64 -url: "https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/3dprinter-klipper" -ingress: true -webui: http://[HOST]:[PORT:7125] -ports: - 7125/tcp: null - 7130/tcp: null -ports_description: - 7125/tcp: Moonraker - 7130/tcp: Fluidd -map: - - addon_config:rw -gpio: true -usb: true -uart: true -options: - host_mcu: false - simulavr: false -schema: - host_mcu: "bool?" - simulavr: "bool?" -panel_icon: mdi:printer-3d -panel_title: 3DPrinter-Klipper -init: false -realtime: true +name: "3DPrinter-Klipper" +version: "2024.2.0" +slug: "3dprinter-klipper" +description: "Klipper with Moonraker and frontend(s) as an addon." +arch: + - armv7 + - amd64 + - armhf + - aarch64 +url: "https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/3dprinter-klipper" +ingress: true +webui: http://[HOST]:[PORT:7125] +ports: + 7125/tcp: null + 7130/tcp: null +ports_description: + 7125/tcp: Moonraker + 7130/tcp: Fluidd +map: + - addon_config:rw +gpio: true +usb: true +uart: true +options: + host_mcu: false + simulavr: false +schema: + host_mcu: "bool?" + simulavr: "bool?" +panel_icon: mdi:printer-3d +panel_title: 3DPrinter-Klipper +init: false +realtime: true diff --git a/3dprinter-klipper/rootfs/etc/caddy/Caddyfile b/3dprinter-klipper/rootfs/etc/caddy/Caddyfile index deaf315..ea51cdd 100644 --- a/3dprinter-klipper/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-klipper/rootfs/etc/caddy/Caddyfile @@ -1,10 +1,10 @@ -{ - # debug - log { - format console - output file /var/log/caddy/caddy.log - } - auto_https disable_redirects -} - -import sites-enabled/*.caddy +{ + # debug + log { + format console + output file /var/log/caddy/caddy.log + } + auto_https disable_redirects +} + +import sites-enabled/*.caddy diff --git a/3dprinter-klipper/rootfs/etc/caddy/env b/3dprinter-klipper/rootfs/etc/caddy/env index 49daa0e..ee0e2e0 100644 --- a/3dprinter-klipper/rootfs/etc/caddy/env +++ b/3dprinter-klipper/rootfs/etc/caddy/env @@ -1,2 +1,2 @@ -XDG_CONFIG_HOME="/data/config" -XDG_DATA_HOME="/data/config" +XDG_CONFIG_HOME="/data/config" +XDG_DATA_HOME="/data/config" diff --git a/3dprinter-klipper/rootfs/etc/cont-init.d/klippy.sh b/3dprinter-klipper/rootfs/etc/cont-init.d/klippy.sh old mode 100644 new mode 100755 index 10bca85..6ae768f --- a/3dprinter-klipper/rootfs/etc/cont-init.d/klippy.sh +++ b/3dprinter-klipper/rootfs/etc/cont-init.d/klippy.sh @@ -1,46 +1,46 @@ -#!/usr/bin/with-contenv bashio - -SRC_PATH=$ADDON_SRC_PATH/klipper -VENV_PATH=$ADDON_VENV_PATH/klipper -CONFIG_PATH=$ADDON_CONFIG_PATH/moonraker/config - -# Get Klipper source. -if [ ! -d "$SRC_PATH" ]; then - bashio::log "Get Klipper source" - git clone https://github.com/Klipper3d/klipper "$SRC_PATH" -else - echo "Klipper already installed" -fi -# Install Klipper in virtual environment. -if [ ! -d "$VENV_PATH" ]; then - bashio::log "Prepare Klippy-env" - virtualenv "$VENV_PATH" - "$VENV_PATH"/bin/python -m pip install --upgrade pip - "$VENV_PATH"/bin/pip install -r "$SRC_PATH"/scripts/klippy-requirements.txt -else - bashio::log "Klippy env already installed" -fi -# Make sure config file(s) exists. -if [ ! -d "$CONFIG_PATH" ]; then - mkdir -p "$CONFIG_PATH" - cp -R /etc/klipper/config/* "$CONFIG_PATH" - ## Create log folder and file - mkdir -p $ADDON_CONFIG_PATH/moonraker/logs - touch $ADDON_CONFIG_PATH/moonraker/logs/klippy.log -fi - -# Build and add host process, if set. -if bashio::config.true 'host_mcu'; then - bashio::log "Enable host process." - BIN_PATH=$ADDON_CONFIG_PATH/bin - if [ ! -f "$BIN_PATH"/klipper_mcu_host ]; then - mkdir -p "$BIN_PATH" - cp /etc/klipper/config_host_mcu "$SRC_PATH"/.config - cd "$SRC_PATH" || exit - make - cp out/klipper.elf "$BIN_PATH"/klipper_mcu_host - fi - rm -f /etc/services.d/klipper_host/down -else - touch /etc/services.d/klipper_host/down -fi +#!/usr/bin/with-contenv bashio + +SRC_PATH=$ADDON_SRC_PATH/klipper +VENV_PATH=$ADDON_VENV_PATH/klipper +CONFIG_PATH=$ADDON_CONFIG_PATH/moonraker/config + +# Get Klipper source. +if [ ! -d "$SRC_PATH" ]; then + bashio::log "Get Klipper source" + git clone https://github.com/Klipper3d/klipper "$SRC_PATH" +else + echo "Klipper already installed" +fi +# Install Klipper in virtual environment. +if [ ! -d "$VENV_PATH" ]; then + bashio::log "Prepare Klippy-env" + virtualenv "$VENV_PATH" + "$VENV_PATH"/bin/python -m pip install --upgrade pip + "$VENV_PATH"/bin/pip install -r "$SRC_PATH"/scripts/klippy-requirements.txt +else + bashio::log "Klippy env already installed" +fi +# Make sure config file(s) exists. +if [ ! -d "$CONFIG_PATH" ]; then + mkdir -p "$CONFIG_PATH" + cp -R /etc/klipper/config/* "$CONFIG_PATH" + ## Create log folder and file + mkdir -p $ADDON_CONFIG_PATH/moonraker/logs + touch $ADDON_CONFIG_PATH/moonraker/logs/klippy.log +fi + +# Build and add host process, if set. +if bashio::config.true 'host_mcu'; then + bashio::log "Enable host process." + BIN_PATH=$ADDON_CONFIG_PATH/bin + if [ ! -f "$BIN_PATH"/klipper_mcu_host ]; then + mkdir -p "$BIN_PATH" + cp /etc/klipper/config_host_mcu "$SRC_PATH"/.config + cd "$SRC_PATH" || exit + make + cp out/klipper.elf "$BIN_PATH"/klipper_mcu_host + fi + rm -f /etc/services.d/klipper_host/down +else + touch /etc/services.d/klipper_host/down +fi diff --git a/3dprinter-klipper/rootfs/etc/cont-init.d/moonraker.sh b/3dprinter-klipper/rootfs/etc/cont-init.d/moonraker.sh old mode 100644 new mode 100755 index c5c7e2e..8098813 --- a/3dprinter-klipper/rootfs/etc/cont-init.d/moonraker.sh +++ b/3dprinter-klipper/rootfs/etc/cont-init.d/moonraker.sh @@ -1,29 +1,29 @@ -#!/usr/bin/with-contenv bashio - -SRC_PATH=$ADDON_SRC_PATH/moonraker -VENV_PATH=$ADDON_VENV_PATH/moonraker -CONFIG_PATH=$ADDON_CONFIG_PATH/moonraker/config - -# Get Moonraker source. -if [ ! -d "$SRC_PATH" ]; then - bashio::log "Get Moonraker source" - git clone https://github.com/Arksine/moonraker.git "$SRC_PATH" -fi -# Install Moonraker in virtual environment. -if [ ! -d "$VENV_PATH" ]; then - bashio::log "Prepare Moonraker-env" - virtualenv "$VENV_PATH" - "$VENV_PATH"/bin/python -m pip install --upgrade pip - "$VENV_PATH"/bin/pip install -r "$SRC_PATH"/scripts/moonraker-requirements.txt - "$VENV_PATH"/bin/pip install msgspec uvloop -else - bashio::log "Moonraker env already installed" -fi -# Make sure config exists. -if [ ! -f "$CONFIG_PATH"/moonraker.conf ]; then - mkdir -p "$CONFIG_PATH" - cp /etc/klipper/config/moonraker.conf "$CONFIG_PATH"/moonraker.conf - ## Create log folder and file - mkdir -p $ADDON_CONFIG_PATH/moonraker/logs - touch $ADDON_CONFIG_PATH/moonraker/logs/moonraker.log -fi +#!/usr/bin/with-contenv bashio + +SRC_PATH=$ADDON_SRC_PATH/moonraker +VENV_PATH=$ADDON_VENV_PATH/moonraker +CONFIG_PATH=$ADDON_CONFIG_PATH/moonraker/config + +# Get Moonraker source. +if [ ! -d "$SRC_PATH" ]; then + bashio::log "Get Moonraker source" + git clone https://github.com/Arksine/moonraker.git "$SRC_PATH" +fi +# Install Moonraker in virtual environment. +if [ ! -d "$VENV_PATH" ]; then + bashio::log "Prepare Moonraker-env" + virtualenv "$VENV_PATH" + "$VENV_PATH"/bin/python -m pip install --upgrade pip + "$VENV_PATH"/bin/pip install -r "$SRC_PATH"/scripts/moonraker-requirements.txt + "$VENV_PATH"/bin/pip install msgspec uvloop +else + bashio::log "Moonraker env already installed" +fi +# Make sure config exists. +if [ ! -f "$CONFIG_PATH"/moonraker.conf ]; then + mkdir -p "$CONFIG_PATH" + cp /etc/klipper/config/moonraker.conf "$CONFIG_PATH"/moonraker.conf + ## Create log folder and file + mkdir -p $ADDON_CONFIG_PATH/moonraker/logs + touch $ADDON_CONFIG_PATH/moonraker/logs/moonraker.log +fi diff --git a/3dprinter-klipper/rootfs/etc/cont-init.d/proxy.sh b/3dprinter-klipper/rootfs/etc/cont-init.d/proxy.sh old mode 100644 new mode 100755 index 162d47b..4876519 --- a/3dprinter-klipper/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-klipper/rootfs/etc/cont-init.d/proxy.sh @@ -1,21 +1,21 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Add-on: 3dprinter-octoprint -# Configures proxy -# ============================================================================== - -# Generate proxy configuration -bashio::var.json \ - addon_hostname "$(bashio::addon.hostname)" \ - addon_ip "$(bashio::addon.ip_address)" \ - trusted_proxies "$(bashio::config 'trusted_proxies')" \ - camera_url "$(bashio::config 'camera_url')" \ - ingress_port "^$(bashio::addon.ingress_port)" \ - fluidd_src "$ADDON_SRC_PATH/fluidd" \ - mainsail_src "$ADDON_SRC_PATH/mainsail" \ - | tempio \ - -template /usr/share/tempio/caddy/Caddyfile.gtpl \ - -out /etc/caddy/sites-enabled/moonraker.caddy - -# Make sure config is correctly formatted. -caddy fmt --overwrite /etc/caddy/Caddyfile +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: 3dprinter-octoprint +# Configures proxy +# ============================================================================== + +# Generate proxy configuration +bashio::var.json \ + addon_hostname "$(bashio::addon.hostname)" \ + addon_ip "$(bashio::addon.ip_address)" \ + trusted_proxies "$(bashio::config 'trusted_proxies')" \ + camera_url "$(bashio::config 'camera_url')" \ + ingress_port "^$(bashio::addon.ingress_port)" \ + fluidd_src "$ADDON_SRC_PATH/fluidd" \ + mainsail_src "$ADDON_SRC_PATH/mainsail" \ + | tempio \ + -template /usr/share/tempio/caddy/Caddyfile.gtpl \ + -out /etc/caddy/sites-enabled/moonraker.caddy + +# Make sure config is correctly formatted. +caddy fmt --overwrite /etc/caddy/Caddyfile diff --git a/3dprinter-klipper/rootfs/etc/cont-init.d/simuavr.sh b/3dprinter-klipper/rootfs/etc/cont-init.d/simuavr.sh old mode 100644 new mode 100755 index 0af56c3..25e751d --- a/3dprinter-klipper/rootfs/etc/cont-init.d/simuavr.sh +++ b/3dprinter-klipper/rootfs/etc/cont-init.d/simuavr.sh @@ -1,30 +1,30 @@ -#!/usr/bin/with-contenv bashio - -SRC_PATH=$ADDON_SRC_PATH/simulavr - -if bashio::config.false 'simulavr'; then - bashio::log "Keep Simulavr disabled." - touch /etc/services.d/simulavr/down - return -else - rm -f /etc/services.d/simulavr/down -fi - -# Install Simuavr -if [ ! -d "$SRC_PATH" ]; then - echo "Get SimulAVR source" - git clone git://git.savannah.nongnu.org/simulavr.git "$SRC_PATH" - cd "$SRC_PATH" || exit - make python - make build -fi - -# Add simulavr process -BIN_PATH=$ADDON_CONFIG_PATH/bin -if [ ! -f "$BIN_PATH"/klipper_mcu_simulavr ]; then - mkdir -p "$BIN_PATH" - cp /etc/klipper/config_simulavr "$ADDON_SRC_PATH"/klipper/.config - cd "$ADDON_SRC_PATH"/klipper || exit - make - cp out/klipper.elf "$BIN_PATH"/klipper_mcu_simulavr.elf -fi +#!/usr/bin/with-contenv bashio + +SRC_PATH=$ADDON_SRC_PATH/simulavr + +if bashio::config.false 'simulavr'; then + bashio::log "Keep Simulavr disabled." + touch /etc/services.d/simulavr/down + return +else + rm -f /etc/services.d/simulavr/down +fi + +# Install Simuavr +if [ ! -d "$SRC_PATH" ]; then + echo "Get SimulAVR source" + git clone git://git.savannah.nongnu.org/simulavr.git "$SRC_PATH" + cd "$SRC_PATH" || exit + make python + make build +fi + +# Add simulavr process +BIN_PATH=$ADDON_CONFIG_PATH/bin +if [ ! -f "$BIN_PATH"/klipper_mcu_simulavr ]; then + mkdir -p "$BIN_PATH" + cp /etc/klipper/config_simulavr "$ADDON_SRC_PATH"/klipper/.config + cd "$ADDON_SRC_PATH"/klipper || exit + make + cp out/klipper.elf "$BIN_PATH"/klipper_mcu_simulavr.elf +fi diff --git a/3dprinter-klipper/rootfs/etc/klipper/config/moonraker.conf b/3dprinter-klipper/rootfs/etc/klipper/config/moonraker.conf index f741f9e..9d67abe 100644 --- a/3dprinter-klipper/rootfs/etc/klipper/config/moonraker.conf +++ b/3dprinter-klipper/rootfs/etc/klipper/config/moonraker.conf @@ -1,28 +1,28 @@ -[server] -host: 0.0.0.0 -port: 7125 - -[authorization] -# force_logins: false -cors_domains: - * -trusted_clients: - 10.0.0.0/8 - 127.0.0.0/8 - 169.254.0.0/16 - 172.16.0.0/12 - 192.168.0.0/16 - FE80::/10 - ::1/128 - -[machine] -provider: none -validate_service: False - -[update_manager] -enable_system_updates: False - -[update_manager fluidd] -type: web -repo: fluidd-core/fluidd -path: /config/src/fluidd +[server] +host: 0.0.0.0 +port: 7125 + +[authorization] +# force_logins: false +cors_domains: + * +trusted_clients: + 10.0.0.0/8 + 127.0.0.0/8 + 169.254.0.0/16 + 172.16.0.0/12 + 192.168.0.0/16 + FE80::/10 + ::1/128 + +[machine] +provider: none +validate_service: False + +[update_manager] +enable_system_updates: False + +[update_manager fluidd] +type: web +repo: fluidd-core/fluidd +path: /config/src/fluidd diff --git a/3dprinter-klipper/rootfs/etc/klipper/config_host_mcu b/3dprinter-klipper/rootfs/etc/klipper/config_host_mcu index 001fe3e..3e30d40 100644 --- a/3dprinter-klipper/rootfs/etc/klipper/config_host_mcu +++ b/3dprinter-klipper/rootfs/etc/klipper/config_host_mcu @@ -1,32 +1,32 @@ -# CONFIG_LOW_LEVEL_OPTIONS is not set -# CONFIG_MACH_AVR is not set -# CONFIG_MACH_ATSAM is not set -# CONFIG_MACH_ATSAMD is not set -# CONFIG_MACH_LPC176X is not set -# CONFIG_MACH_STM32 is not set -# CONFIG_MACH_HC32F460 is not set -# CONFIG_MACH_RP2040 is not set -# CONFIG_MACH_PRU is not set -# CONFIG_MACH_AR100 is not set -CONFIG_MACH_LINUX=y -# CONFIG_MACH_SIMU is not set -CONFIG_BOARD_DIRECTORY="linux" -CONFIG_CLOCK_FREQ=50000000 -CONFIG_LINUX_SELECT=y -CONFIG_USB_VENDOR_ID=0x1d50 -CONFIG_USB_DEVICE_ID=0x614e -CONFIG_USB_SERIAL_NUMBER="12345" -CONFIG_WANT_GPIO_BITBANGING=y -CONFIG_WANT_DISPLAYS=y -CONFIG_WANT_SENSORS=y -CONFIG_WANT_LIS2DW=y -CONFIG_WANT_SOFTWARE_I2C=y -CONFIG_WANT_SOFTWARE_SPI=y -CONFIG_NEED_SENSOR_BULK=y -CONFIG_CANBUS_FREQUENCY=1000000 -CONFIG_HAVE_GPIO=y -CONFIG_HAVE_GPIO_ADC=y -CONFIG_HAVE_GPIO_SPI=y -CONFIG_HAVE_GPIO_I2C=y -CONFIG_HAVE_GPIO_HARD_PWM=y -CONFIG_INLINE_STEPPER_HACK=y +# CONFIG_LOW_LEVEL_OPTIONS is not set +# CONFIG_MACH_AVR is not set +# CONFIG_MACH_ATSAM is not set +# CONFIG_MACH_ATSAMD is not set +# CONFIG_MACH_LPC176X is not set +# CONFIG_MACH_STM32 is not set +# CONFIG_MACH_HC32F460 is not set +# CONFIG_MACH_RP2040 is not set +# CONFIG_MACH_PRU is not set +# CONFIG_MACH_AR100 is not set +CONFIG_MACH_LINUX=y +# CONFIG_MACH_SIMU is not set +CONFIG_BOARD_DIRECTORY="linux" +CONFIG_CLOCK_FREQ=50000000 +CONFIG_LINUX_SELECT=y +CONFIG_USB_VENDOR_ID=0x1d50 +CONFIG_USB_DEVICE_ID=0x614e +CONFIG_USB_SERIAL_NUMBER="12345" +CONFIG_WANT_GPIO_BITBANGING=y +CONFIG_WANT_DISPLAYS=y +CONFIG_WANT_SENSORS=y +CONFIG_WANT_LIS2DW=y +CONFIG_WANT_SOFTWARE_I2C=y +CONFIG_WANT_SOFTWARE_SPI=y +CONFIG_NEED_SENSOR_BULK=y +CONFIG_CANBUS_FREQUENCY=1000000 +CONFIG_HAVE_GPIO=y +CONFIG_HAVE_GPIO_ADC=y +CONFIG_HAVE_GPIO_SPI=y +CONFIG_HAVE_GPIO_I2C=y +CONFIG_HAVE_GPIO_HARD_PWM=y +CONFIG_INLINE_STEPPER_HACK=y diff --git a/3dprinter-klipper/rootfs/etc/services.d/klipper_host/down b/3dprinter-klipper/rootfs/etc/services.d/klipper_host/down old mode 100644 new mode 100755 diff --git a/3dprinter-klipper/rootfs/etc/services.d/klipper_host/run b/3dprinter-klipper/rootfs/etc/services.d/klipper_host/run old mode 100644 new mode 100755 index e86d562..fee22e8 --- a/3dprinter-klipper/rootfs/etc/services.d/klipper_host/run +++ b/3dprinter-klipper/rootfs/etc/services.d/klipper_host/run @@ -1,10 +1,10 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Add-on: 3dprinter-Klipper -# Runs Host Sim MCU -# ============================================================================== - -bashio::log.info "Starting Host MCU..." - -## Run your program -exec "$ADDON_CONFIG_PATH"/bin/klipper_mcu_host +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: 3dprinter-Klipper +# Runs Host Sim MCU +# ============================================================================== + +bashio::log.info "Starting Host MCU..." + +## Run your program +exec "$ADDON_CONFIG_PATH"/bin/klipper_mcu_host diff --git a/3dprinter-klipper/rootfs/etc/services.d/klippy/run b/3dprinter-klipper/rootfs/etc/services.d/klippy/run old mode 100644 new mode 100755 index b500c0b..062c730 --- a/3dprinter-klipper/rootfs/etc/services.d/klippy/run +++ b/3dprinter-klipper/rootfs/etc/services.d/klippy/run @@ -1,19 +1,19 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Add-on: 3dprinter-Klipper -# Runs Klippy -# ============================================================================== - -bashio::log.info "Starting Klippy..." - - -if bashio::config.true 'host_mcu'; then - while [ ! -e /tmp/klipper_host_mcu ] - do - bashio::log "Wait for klipper_host_mcu" - sleep 5 - done -fi - -## Run your program -exec "$ADDON_VENV_PATH"/klipper/bin/python "$ADDON_SRC_PATH"/klipper/klippy/klippy.py "$ADDON_CONFIG_PATH"/moonraker/config/printer.cfg -a /tmp/klippy_uds -l "$ADDON_CONFIG_PATH"/moonraker/logs/klippy.log +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: 3dprinter-Klipper +# Runs Klippy +# ============================================================================== + +bashio::log.info "Starting Klippy..." + + +if bashio::config.true 'host_mcu'; then + while [ ! -e /tmp/klipper_host_mcu ] + do + bashio::log "Wait for klipper_host_mcu" + sleep 5 + done +fi + +## Run your program +exec "$ADDON_VENV_PATH"/klipper/bin/python "$ADDON_SRC_PATH"/klipper/klippy/klippy.py "$ADDON_CONFIG_PATH"/moonraker/config/printer.cfg -a /tmp/klippy_uds -l "$ADDON_CONFIG_PATH"/moonraker/logs/klippy.log diff --git a/3dprinter-klipper/rootfs/etc/services.d/moonraker/run b/3dprinter-klipper/rootfs/etc/services.d/moonraker/run old mode 100644 new mode 100755 index 97b2098..73a7913 --- a/3dprinter-klipper/rootfs/etc/services.d/moonraker/run +++ b/3dprinter-klipper/rootfs/etc/services.d/moonraker/run @@ -1,14 +1,14 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Add-on: 3dprinter-Klipper -# Runs Moonraker -# ============================================================================== - -bashio::log.info "Starting Moonraker..." - -## Preparations, create log folder and file -mkdir -p "$ADDON_CONFIG_PATH"/moonraker/logs -touch "$ADDON_CONFIG_PATH"/moonraker/logs/moonraker.log - -## Run your program -exec "$ADDON_VENV_PATH"/moonraker/bin/python "$ADDON_SRC_PATH"/moonraker/moonraker/moonraker.py -d "$ADDON_CONFIG_PATH"/moonraker -v +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: 3dprinter-Klipper +# Runs Moonraker +# ============================================================================== + +bashio::log.info "Starting Moonraker..." + +## Preparations, create log folder and file +mkdir -p "$ADDON_CONFIG_PATH"/moonraker/logs +touch "$ADDON_CONFIG_PATH"/moonraker/logs/moonraker.log + +## Run your program +exec "$ADDON_VENV_PATH"/moonraker/bin/python "$ADDON_SRC_PATH"/moonraker/moonraker/moonraker.py -d "$ADDON_CONFIG_PATH"/moonraker -v diff --git a/3dprinter-klipper/rootfs/etc/services.d/proxy/run b/3dprinter-klipper/rootfs/etc/services.d/proxy/run old mode 100644 new mode 100755 index eb858f3..911d49a --- a/3dprinter-klipper/rootfs/etc/services.d/proxy/run +++ b/3dprinter-klipper/rootfs/etc/services.d/proxy/run @@ -1,9 +1,9 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Add-on: 3dprinter-octoprint -# Runs the reverse proxy. -# ============================================================================== - -bashio::log.info "Starting proxy..." - -exec caddy run --config /etc/caddy/Caddyfile --envfile /etc/caddy/env +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: 3dprinter-octoprint +# Runs the reverse proxy. +# ============================================================================== + +bashio::log.info "Starting proxy..." + +exec caddy run --config /etc/caddy/Caddyfile --envfile /etc/caddy/env diff --git a/3dprinter-klipper/rootfs/etc/services.d/simulavr/run b/3dprinter-klipper/rootfs/etc/services.d/simulavr/run old mode 100644 new mode 100755 index bbcb11b..aea11ca --- a/3dprinter-klipper/rootfs/etc/services.d/simulavr/run +++ b/3dprinter-klipper/rootfs/etc/services.d/simulavr/run @@ -1,11 +1,11 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Add-on: 3dprinter-Klipper -# Runs Host SimulAVR MCU -# ============================================================================== - -bashio::log.info "Starting SimulAVR MCU..." - -## Run your program -export PYTHONPATH=$ADDON_SRC_PATH/simulavr/build/pysimulavr -exec "$ADDON_SRC_PATH"/klipper/scripts/avrsim.py "$ADDON_CONFIG_PATH"/bin/klipper_mcu_simulavr.elf +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: 3dprinter-Klipper +# Runs Host SimulAVR MCU +# ============================================================================== + +bashio::log.info "Starting SimulAVR MCU..." + +## Run your program +export PYTHONPATH=$ADDON_SRC_PATH/simulavr/build/pysimulavr +exec "$ADDON_SRC_PATH"/klipper/scripts/avrsim.py "$ADDON_CONFIG_PATH"/bin/klipper_mcu_simulavr.elf diff --git a/3dprinter-klipper/rootfs/usr/share/tempio/caddy/Caddyfile.gtpl b/3dprinter-klipper/rootfs/usr/share/tempio/caddy/Caddyfile.gtpl index 3f74ed7..4ac08d8 100644 --- a/3dprinter-klipper/rootfs/usr/share/tempio/caddy/Caddyfile.gtpl +++ b/3dprinter-klipper/rootfs/usr/share/tempio/caddy/Caddyfile.gtpl @@ -1,16 +1,16 @@ -(fluidd) { - root * {{ .fluidd_src }} - file_server -} - -# Ingress -:8099 { - handle /websocket* { - reverse_proxy http://127.0.0.1:7125 - } - import fluidd -} -# Fluidd -:7130 { - import fluidd -} +(fluidd) { + root * {{ .fluidd_src }} + file_server +} + +# Ingress +:8099 { + handle /websocket* { + reverse_proxy http://127.0.0.1:7125 + } + import fluidd +} +# Fluidd +:7130 { + import fluidd +} diff --git a/3dprinter-octoprint/CHANGELOG.md b/3dprinter-octoprint/CHANGELOG.md index 9cb16df..2e071c8 100644 --- a/3dprinter-octoprint/CHANGELOG.md +++ b/3dprinter-octoprint/CHANGELOG.md @@ -1,35 +1,35 @@ -## 2024.01.2 - * Add option to pass webcam URL to proxy. - -## 2024.01.1 - - * Maintenance release: - * Update base image. - * Update default OctoPrint version to 1.9.3. - -## 2023.03.1 - * Add check that OctoPrint can install at buildtime. - * Add missing dependency for armhf (libffi-dev) - -## 2023.03.0 - * Mark 3DPrinter-OctoPrint stable - * Set realtime flag - * Enable AppArmor - -## 2023.02.0 - * Add binaries for flashing firmware to printer (avrdude, dfu-util, dfu-programmer, stm32flash). - -## 2023.01.2 - * Disable AppArmor profile. - -## 2023.01.1 - * Add AppArmor profile - * Add support for GPIO - -## 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. +## 2024.01.2 + * Add option to pass webcam URL to proxy. + +## 2024.01.1 + + * Maintenance release: + * Update base image. + * Update default OctoPrint version to 1.9.3. + +## 2023.03.1 + * Add check that OctoPrint can install at buildtime. + * Add missing dependency for armhf (libffi-dev) + +## 2023.03.0 + * Mark 3DPrinter-OctoPrint stable + * Set realtime flag + * Enable AppArmor + +## 2023.02.0 + * Add binaries for flashing firmware to printer (avrdude, dfu-util, dfu-programmer, stm32flash). + +## 2023.01.2 + * Disable AppArmor profile. + +## 2023.01.1 + * Add AppArmor profile + * Add support for GPIO + +## 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. diff --git a/3dprinter-octoprint/DOCS.md b/3dprinter-octoprint/DOCS.md index 7325638..6282bd2 100644 --- a/3dprinter-octoprint/DOCS.md +++ b/3dprinter-octoprint/DOCS.md @@ -1,39 +1,39 @@ -# Startup - -Set a network port in add-on settings to be able to access the WebUI. - -# Add-on configuration - -## Trusted proxies - -*If you have placed a reverse proxy in front of Home Assistant*, by setting trusted proxies you should be able to use HTTPS. For more information, see [Caddy documentation](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy). - -## Camera URL - -By entering a URL to a camera you can make it available at `/camera/`. Note that this means that anyone with access to your OctoPrint instance can access the stream (even if not signed in! https://community.octoprint.org/t/why-is-there-no-access-control-for-the-webcam-in-octoprint-why-is-my-webcam-always-on/233). **Making this secure is up to you!** - -# OctoPrint integration - -You can use the OctoPrint integration with this add-on. Go to Home Assistant, add integration OctoPrint, and use the following: -- Host: `cce6f2d5-3dprinter-octoprint` (use the add-on hostname, the first part could differ). -- port: 5000 -- Don't use SSL (leave unchecked) - -Go to OctoPrint WebUI, you should see a request for authentication. - -# Camera - -This add-on does not include a camera server, that has to be installed and setup separately. - -You could, for instance, use the add-on [camera-mjpg-streamer](https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/camera-mjpg-streamer) available in the same repository. This will work for snapshots, but not necessarily for video as the video stream has to be available by the browser/app directly, **not just the host running OctoPrint**. - -Instead of exposing the video stream directly, you could try to use the `Camera URL` option. **Note that this is mostly untested.** In theory you should be able to: -* Install the [camera-mjpg-streamer](https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/camera-mjpg-streamer) add-on. Start it and make sure you can see the image from the camera in that add-on. -* In options for this add-on, set `Camera URL` to hostname of the add-on where the camera is running, e.g. `http://cce6f2d5-camera-mjpg-streamer`. -* In OctoPrint, set: - * `Stream URL` to `http:///camera/?action=stream` - * `Snapshot URL` to `http:///camera/?action=snapshot`. This will make it easier to check that it works, but should later be changed to the local URL, e.g. `http://cce6f2d5-camera-mjpg-streamer/?action=snapshot`. - -# Remote access - -If you need remote access, have a look at [remote access plugins for OctoPrint](https://plugins.octoprint.org/topics/remote_access/). Remember to **NEVER** directly portforward your OctoPrint instance to the internet! +# Startup + +Set a network port in add-on settings to be able to access the WebUI. + +# Add-on configuration + +## Trusted proxies + +*If you have placed a reverse proxy in front of Home Assistant*, by setting trusted proxies you should be able to use HTTPS. For more information, see [Caddy documentation](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy). + +## Camera URL + +By entering a URL to a camera you can make it available at `/camera/`. Note that this means that anyone with access to your OctoPrint instance can access the stream (even if not signed in! https://community.octoprint.org/t/why-is-there-no-access-control-for-the-webcam-in-octoprint-why-is-my-webcam-always-on/233). **Making this secure is up to you!** + +# OctoPrint integration + +You can use the OctoPrint integration with this add-on. Go to Home Assistant, add integration OctoPrint, and use the following: +- Host: `cce6f2d5-3dprinter-octoprint` (use the add-on hostname, the first part could differ). +- port: 5000 +- Don't use SSL (leave unchecked) + +Go to OctoPrint WebUI, you should see a request for authentication. + +# Camera + +This add-on does not include a camera server, that has to be installed and setup separately. + +You could, for instance, use the add-on [camera-mjpg-streamer](https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/camera-mjpg-streamer) available in the same repository. This will work for snapshots, but not necessarily for video as the video stream has to be available by the browser/app directly, **not just the host running OctoPrint**. + +Instead of exposing the video stream directly, you could try to use the `Camera URL` option. **Note that this is mostly untested.** In theory you should be able to: +* Install the [camera-mjpg-streamer](https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/camera-mjpg-streamer) add-on. Start it and make sure you can see the image from the camera in that add-on. +* In options for this add-on, set `Camera URL` to hostname of the add-on where the camera is running, e.g. `http://cce6f2d5-camera-mjpg-streamer`. +* In OctoPrint, set: + * `Stream URL` to `http:///camera/?action=stream` + * `Snapshot URL` to `http:///camera/?action=snapshot`. This will make it easier to check that it works, but should later be changed to the local URL, e.g. `http://cce6f2d5-camera-mjpg-streamer/?action=snapshot`. + +# Remote access + +If you need remote access, have a look at [remote access plugins for OctoPrint](https://plugins.octoprint.org/topics/remote_access/). Remember to **NEVER** directly portforward your OctoPrint instance to the internet! diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 775f30b..ad2d5ac 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,52 +1,52 @@ -ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" -FROM ${BUILD_FROM} -ARG OCTOPRINT_VERSION="1.9.3" - -# 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 \ - libffi-dev \ - # 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 - -# Test install, verify that install will be possible. -RUN sed 's/#!/# #!/' /etc/cont-init.d/octoprint.sh > /tmp/octoprint.sh -RUN bash /tmp/octoprint.sh \ - && rm -rf /data/* /tmp/* +ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" +FROM ${BUILD_FROM} +ARG OCTOPRINT_VERSION="1.9.3" + +# 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 \ + libffi-dev \ + # 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 + +# Test install, verify that install will be possible. +RUN sed 's/#!/# #!/' /etc/cont-init.d/octoprint.sh > /tmp/octoprint.sh +RUN bash /tmp/octoprint.sh \ + && rm -rf /data/* /tmp/* diff --git a/3dprinter-octoprint/README.md b/3dprinter-octoprint/README.md index 2186808..fe8e6bc 100644 --- a/3dprinter-octoprint/README.md +++ b/3dprinter-octoprint/README.md @@ -1,9 +1,9 @@ -# 3DPrinter-OctoPrint - -Provides OctoPrint as an addon to Home Assistant. - -## Instructions - -Set a network port in addon settings. - -For more details, see the Documentation tab. +# 3DPrinter-OctoPrint + +Provides OctoPrint as an addon to Home Assistant. + +## Instructions + +Set a network port in addon settings. + +For more details, see the Documentation tab. diff --git a/3dprinter-octoprint/apparmor.txt b/3dprinter-octoprint/apparmor.txt index d3480bc..787dd7a 100644 --- a/3dprinter-octoprint/apparmor.txt +++ b/3dprinter-octoprint/apparmor.txt @@ -1,57 +1,57 @@ -#include - -profile 3dprinter-octoprint flags=(attach_disconnected,mediate_deleted) { - #include - - # Capabilities - file, - signal (send) set=(kill,term,int,hup,cont), - - # S6-Overlay - /init ix, - /bin/** ix, - /usr/bin/** ix, - /run/{s6,s6-rc*,service}/** ix, - /package/** ix, - /command/** ix, - /etc/services.d/** rwix, - /etc/cont-init.d/** rwix, - /etc/cont-finish.d/** rwix, - /run/{,**} rwk, - /dev/tty rw, - - # Bashio - /usr/lib/bashio/** ix, - /tmp/** rwk, - - # Access to options.json and other files within your addon - /data/** rw, - - # Start new profile for service - /usr/bin/caddy cx -> caddy, - - profile caddy flags=(attach_disconnected,mediate_deleted) { - #include - - # Receive signals from S6-Overlay - signal (receive) peer=*_3dprinter-octoprint, - - capability dac_override, - - owner /usr/bin/caddy rm, - @{HOME}/.step/ w, - @{PROC}/*/cpuset r, - @{PROC}/sys/net/** r, - - /etc/** r, - owner /etc/caddy/ kwr, - owner /etc/caddy/** kwrml, - - /var/log/caddy/ r, - owner /var/log/caddy/ kwr, - owner /var/log/caddy/** kwrml, - - owner /data/config/caddy/ kwr, - owner /data/config/caddy/** kwrml, - } +#include + +profile 3dprinter-octoprint flags=(attach_disconnected,mediate_deleted) { + #include + + # Capabilities + file, + signal (send) set=(kill,term,int,hup,cont), + + # S6-Overlay + /init ix, + /bin/** ix, + /usr/bin/** ix, + /run/{s6,s6-rc*,service}/** ix, + /package/** ix, + /command/** ix, + /etc/services.d/** rwix, + /etc/cont-init.d/** rwix, + /etc/cont-finish.d/** rwix, + /run/{,**} rwk, + /dev/tty rw, + + # Bashio + /usr/lib/bashio/** ix, + /tmp/** rwk, + + # Access to options.json and other files within your addon + /data/** rw, + + # Start new profile for service + /usr/bin/caddy cx -> caddy, + + profile caddy flags=(attach_disconnected,mediate_deleted) { + #include + + # Receive signals from S6-Overlay + signal (receive) peer=*_3dprinter-octoprint, + + capability dac_override, + + owner /usr/bin/caddy rm, + @{HOME}/.step/ w, + @{PROC}/*/cpuset r, + @{PROC}/sys/net/** r, + + /etc/** r, + owner /etc/caddy/ kwr, + owner /etc/caddy/** kwrml, + + /var/log/caddy/ r, + owner /var/log/caddy/ kwr, + owner /var/log/caddy/** kwrml, + + owner /data/config/caddy/ kwr, + owner /data/config/caddy/** kwrml, + } } \ No newline at end of file diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 0e4c766..f05d7d6 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -1,11 +1,11 @@ -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 -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/ha-3dprinter-addons" -args: - OCTOPRINT_VERSION: "1.9.3" +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 +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/ha-3dprinter-addons" +args: + OCTOPRINT_VERSION: "1.9.3" diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index b0d5b3c..d82e0ba 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,33 +1,33 @@ -name: "3DPrinter-OctoPrint" -version: "2024.01.2" -slug: "3dprinter-octoprint" -description: "OctoPrint as an addon, no additional bells and whistles." -arch: - - armv7 - - amd64 - - armhf - - aarch64 -url: "https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/3dprinter-octoprint" -webui: http://[HOST]:[PORT:5000] -ports: - 5000/tcp: null -ports_description: - 5000/tcp: Web-based interface -devices: - - "/dev/i2c-0" - - "/dev/i2c-1" -gpio: true -usb: true -uart: true -options: - trusted_proxies: "" - camera_url: "" -schema: - trusted_proxies: "str?" - camera_url: "str?" -image: ghcr.io/fredrikbaberg/ha-addon-3dprinter-octoprint-{arch} -tmpfs: true -panel_icon: mdi:printer-3d -panel_title: 3DPrinter-OctoPrint -init: false -realtime: true +name: "3DPrinter-OctoPrint" +version: "2024.01.2" +slug: "3dprinter-octoprint" +description: "OctoPrint as an addon, no additional bells and whistles." +arch: + - armv7 + - amd64 + - armhf + - aarch64 +url: "https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/3dprinter-octoprint" +webui: http://[HOST]:[PORT:5000] +ports: + 5000/tcp: null +ports_description: + 5000/tcp: Web-based interface +devices: + - "/dev/i2c-0" + - "/dev/i2c-1" +gpio: true +usb: true +uart: true +options: + trusted_proxies: "" + camera_url: "" +schema: + trusted_proxies: "str?" + camera_url: "str?" +image: ghcr.io/fredrikbaberg/ha-addon-3dprinter-octoprint-{arch} +tmpfs: true +panel_icon: mdi:printer-3d +panel_title: 3DPrinter-OctoPrint +init: false +realtime: true diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index deaf315..ea51cdd 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -1,10 +1,10 @@ -{ - # debug - log { - format console - output file /var/log/caddy/caddy.log - } - auto_https disable_redirects -} - -import sites-enabled/*.caddy +{ + # debug + log { + format console + output file /var/log/caddy/caddy.log + } + auto_https disable_redirects +} + +import sites-enabled/*.caddy diff --git a/3dprinter-octoprint/rootfs/etc/caddy/env b/3dprinter-octoprint/rootfs/etc/caddy/env index 49daa0e..ee0e2e0 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/env +++ b/3dprinter-octoprint/rootfs/etc/caddy/env @@ -1,2 +1,2 @@ -XDG_CONFIG_HOME="/data/config" -XDG_DATA_HOME="/data/config" +XDG_CONFIG_HOME="/data/config" +XDG_DATA_HOME="/data/config" diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index bf03afd..9fafb2c 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -1,54 +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. -# } +#!/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. +# } diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh index b01dff7..120c183 100755 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -1,34 +1,34 @@ -#!/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')" \ - camera_url "$(bashio::config 'camera_url')" \ - | 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. +#!/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')" \ + camera_url "$(bashio::config 'camera_url')" \ + | 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 \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish index ff80240..5498e77 100755 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish @@ -1,10 +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 +#!/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 diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run index 95750a1..96fb146 100755 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run @@ -1,10 +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 +#!/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 diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish index 14df06e..b18c664 100755 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish @@ -1,5 +1,5 @@ -#!/usr/bin/execlineb -S0 -# ============================================================================== -# Add-on: 3dprinter-octoprint -# Stop reverse proxy -# ============================================================================== +#!/usr/bin/execlineb -S0 +# ============================================================================== +# Add-on: 3dprinter-octoprint +# Stop reverse proxy +# ============================================================================== diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run index 0edf12f..bf491b0 100755 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run @@ -1,12 +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 +#!/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 diff --git a/3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh b/3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh index 874f9a4..aa4fa17 100755 --- a/3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh +++ b/3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh @@ -1,5 +1,5 @@ -#!/usr/bin/with-contenv bashio - -bashio::log.warning "Restart OctoPrint." - -s6-svc -r /var/run/s6/legacy-services/octoprint +#!/usr/bin/with-contenv bashio + +bashio::log.warning "Restart OctoPrint." + +s6-svc -r /var/run/s6/legacy-services/octoprint diff --git a/3dprinter-octoprint/rootfs/scripts/proxy_restart.sh b/3dprinter-octoprint/rootfs/scripts/proxy_restart.sh index 4ec7fd8..82597bc 100755 --- a/3dprinter-octoprint/rootfs/scripts/proxy_restart.sh +++ b/3dprinter-octoprint/rootfs/scripts/proxy_restart.sh @@ -1,5 +1,5 @@ -#!/usr/bin/with-contenv bashio - -bashio::log.warning "Restart proxy." - -s6-svc -r /var/run/s6/legacy-services/proxy +#!/usr/bin/with-contenv bashio + +bashio::log.warning "Restart proxy." + +s6-svc -r /var/run/s6/legacy-services/proxy diff --git a/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh b/3dprinter-octoprint/rootfs/scripts/set_octoprint_config.sh index cd6e54b..44b4505 100755 --- 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. - -# 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" -# } +# #!/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 diff --git a/3dprinter-octoprint/rootfs/scripts/system_restart.sh b/3dprinter-octoprint/rootfs/scripts/system_restart.sh index a224d4d..6b3867e 100755 --- a/3dprinter-octoprint/rootfs/scripts/system_restart.sh +++ b/3dprinter-octoprint/rootfs/scripts/system_restart.sh @@ -1,5 +1,5 @@ -#!/usr/bin/with-contenv bashio - -bashio::log.warning "Restart addon." - -bashio::addon.restart +#!/usr/bin/with-contenv bashio + +bashio::log.warning "Restart addon." + +bashio::addon.restart diff --git a/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh b/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh index 59972e3..ed92912 100755 --- a/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh +++ b/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh @@ -1,5 +1,5 @@ -#!/usr/bin/with-contenv bashio - -bashio::log.warning "Shutdown addon." - -bashio::addon.stop +#!/usr/bin/with-contenv bashio + +bashio::log.warning "Shutdown addon." + +bashio::addon.stop diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/caddy/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/caddy/Caddyfile.ingress.gtpl index a5751b1..d2476d9 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/caddy/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/caddy/Caddyfile.ingress.gtpl @@ -1,46 +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 -# } -# } -# } +:{{ .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 +# } +# } +# } # \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/caddy/Caddyfile.internal_external.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/caddy/Caddyfile.internal_external.gtpl index 5dde701..998f5fb 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/caddy/Caddyfile.internal_external.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/caddy/Caddyfile.internal_external.gtpl @@ -1,16 +1,16 @@ -# Internal and external access. Used for: -# * Home-Assistant OctoPrint integration. -# * Accessing OctoPrint WebUI through external port. -:5000 { - {{ if .camera_url }} - handle_path /camera* { - reverse_proxy {{ .camera_url }} { - trusted_proxies {{ .trusted_proxies }} - flush_interval -1 - } - } - {{ end }} - reverse_proxy http://127.0.0.1:80 { - trusted_proxies {{ .trusted_proxies }} - } -} +# Internal and external access. Used for: +# * Home-Assistant OctoPrint integration. +# * Accessing OctoPrint WebUI through external port. +:5000 { + {{ if .camera_url }} + handle_path /camera* { + reverse_proxy {{ .camera_url }} { + trusted_proxies {{ .trusted_proxies }} + flush_interval -1 + } + } + {{ end }} + reverse_proxy http://127.0.0.1:80 { + trusted_proxies {{ .trusted_proxies }} + } +} diff --git a/3dprinter-remote/CHANGELOG.md b/3dprinter-remote/CHANGELOG.md index 692993b..2de684e 100644 --- a/3dprinter-remote/CHANGELOG.md +++ b/3dprinter-remote/CHANGELOG.md @@ -1,3 +1,3 @@ -## 2024.01.0 - +## 2024.01.0 + * Maintenance release \ No newline at end of file diff --git a/3dprinter-remote/Dockerfile b/3dprinter-remote/Dockerfile index 54bc39d..c659177 100644 --- a/3dprinter-remote/Dockerfile +++ b/3dprinter-remote/Dockerfile @@ -1,14 +1,14 @@ -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 ser2net -COPY rootfs/ / -WORKDIR / - -# Make files executable -RUN chmod +x /etc/cont-init.d/*.sh -RUN chmod +x /etc/services.d/*/* +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 ser2net +COPY rootfs/ / +WORKDIR / + +# Make files executable +RUN chmod +x /etc/cont-init.d/*.sh +RUN chmod +x /etc/services.d/*/* diff --git a/3dprinter-remote/README.md b/3dprinter-remote/README.md index a649c5c..0ab8696 100644 --- a/3dprinter-remote/README.md +++ b/3dprinter-remote/README.md @@ -1,12 +1,12 @@ -# 3DPrinter-Remote - -Provides remote access to 3DPrinter. Add-on runs ser2net and can be connected to by e.g. socat. - -## Usage - -On the machine connected to the printer (`remote machine`): -* Setup the add-on. At minimum you will need to specify `printer_path` and verify that `baud_rate` is correct. - -On the machine with OctoPrint: -* Go to Settings --> Serial Connection, section __Additional serial ports__. Add : `socket://:9999`. For example, use the IP for `remote machine`. +# 3DPrinter-Remote + +Provides remote access to 3DPrinter. Add-on runs ser2net and can be connected to by e.g. socat. + +## Usage + +On the machine connected to the printer (`remote machine`): +* Setup the add-on. At minimum you will need to specify `printer_path` and verify that `baud_rate` is correct. + +On the machine with OctoPrint: +* Go to Settings --> Serial Connection, section __Additional serial ports__. Add : `socket://:9999`. For example, use the IP for `remote machine`. * Install plugin [OctoPrint-Network-Printing](https://github.com/hellerbarde/OctoPrint-Network-Printing) \ No newline at end of file diff --git a/3dprinter-remote/config.yaml b/3dprinter-remote/config.yaml index 6ecfc9c..a94f248 100644 --- a/3dprinter-remote/config.yaml +++ b/3dprinter-remote/config.yaml @@ -1,29 +1,29 @@ -name: "3DPrinter-Remote" -version: "2024.01.0" -slug: "3dprinter-remote" -description: "Add-on for accessing 3DPrinter remotely using socat" -url: "https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/3dprinter-remote" -arch: - - armv7 - - amd64 - - armhf - - aarch64 - - i386 -stage: experimental -init: false -gpio: true -usb: true -uart: true -ports: - 9999/tcp: 9999 -ports_description: - 9999/tcp: Port for access to ser2net -options: - printer_path: "/dev/null" - printer_baudrate: "115200" - ser2net_args: "" -schema: - printer_path: "str" - printer_baudrate: "int" - ser2net_args: "str?" -image: ghcr.io/fredrikbaberg/ha-addon-3dprinter-remote-{arch} +name: "3DPrinter-Remote" +version: "2024.01.0" +slug: "3dprinter-remote" +description: "Add-on for accessing 3DPrinter remotely using socat" +url: "https://github.com/fredrikbaberg/ha-3dprinter-addons/tree/main/3dprinter-remote" +arch: + - armv7 + - amd64 + - armhf + - aarch64 + - i386 +stage: experimental +init: false +gpio: true +usb: true +uart: true +ports: + 9999/tcp: 9999 +ports_description: + 9999/tcp: Port for access to ser2net +options: + printer_path: "/dev/null" + printer_baudrate: "115200" + ser2net_args: "" +schema: + printer_path: "str" + printer_baudrate: "int" + ser2net_args: "str?" +image: ghcr.io/fredrikbaberg/ha-addon-3dprinter-remote-{arch} diff --git a/3dprinter-remote/rootfs/etc/cont-init.d/ser2net.sh b/3dprinter-remote/rootfs/etc/cont-init.d/ser2net.sh index 96456b3..e773cb8 100644 --- a/3dprinter-remote/rootfs/etc/cont-init.d/ser2net.sh +++ b/3dprinter-remote/rootfs/etc/cont-init.d/ser2net.sh @@ -1,14 +1,14 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Add-on: 3dprinter-remote -# Setup ser2net.conf -# ============================================================================== - -# Generate ser2net configuration -bashio::var.json \ - printer_path "$(bashio::config 'printer_path')" \ - printer_baudrate "$(bashio::config 'printer_baudrate')" \ - ser2net_args "$(bashio::config 'ser2net_args')" \ - | tempio \ - -template /usr/share/tempio/ser2net/ser2net.conf.gtpl \ - -out /etc/ser2net.conf +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: 3dprinter-remote +# Setup ser2net.conf +# ============================================================================== + +# Generate ser2net configuration +bashio::var.json \ + printer_path "$(bashio::config 'printer_path')" \ + printer_baudrate "$(bashio::config 'printer_baudrate')" \ + ser2net_args "$(bashio::config 'ser2net_args')" \ + | tempio \ + -template /usr/share/tempio/ser2net/ser2net.conf.gtpl \ + -out /etc/ser2net.conf diff --git a/3dprinter-remote/rootfs/etc/services.d/ser2net/finish b/3dprinter-remote/rootfs/etc/services.d/ser2net/finish index 1ecc5e9..ee3f07b 100644 --- a/3dprinter-remote/rootfs/etc/services.d/ser2net/finish +++ b/3dprinter-remote/rootfs/etc/services.d/ser2net/finish @@ -1,9 +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 +#!/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 diff --git a/3dprinter-remote/rootfs/etc/services.d/ser2net/run b/3dprinter-remote/rootfs/etc/services.d/ser2net/run index acfbd63..10a46cd 100644 --- a/3dprinter-remote/rootfs/etc/services.d/ser2net/run +++ b/3dprinter-remote/rootfs/etc/services.d/ser2net/run @@ -1,9 +1,9 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# Add-on: 3dprinter-remote -# Runs ser2net -# ============================================================================== - -bashio::log.info "Starting ser2net.." - -exec ser2net -d +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Add-on: 3dprinter-remote +# Runs ser2net +# ============================================================================== + +bashio::log.info "Starting ser2net.." + +exec ser2net -d diff --git a/3dprinter-remote/rootfs/usr/share/tempio/ser2net/ser2net.conf.gtpl b/3dprinter-remote/rootfs/usr/share/tempio/ser2net/ser2net.conf.gtpl index 9fbc5bb..cfbc0c5 100644 --- a/3dprinter-remote/rootfs/usr/share/tempio/ser2net/ser2net.conf.gtpl +++ b/3dprinter-remote/rootfs/usr/share/tempio/ser2net/ser2net.conf.gtpl @@ -1,2 +1,2 @@ -9999:raw:0:{{ .printer_path }}:{{ .printer_baudrate }} {{ .ser2net_args }} -BANNER:banner1:Welcome to ser2net \rTCP port \p device \d\r +9999:raw:0:{{ .printer_path }}:{{ .printer_baudrate }} {{ .ser2net_args }} +BANNER:banner1:Welcome to ser2net \rTCP port \p device \d\r diff --git a/README.md b/README.md index 355115e..c3cab01 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ -# 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. - -[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Ffredrikbaberg%2Fha-3dprinter-addons) - - -## Addons - -### 3DPrinter-OctoPrint - -OctoPrint, plain and simple. - -### 3DPrinter-Remote - -Run OctoPrint on a different machine from the printer. - -### Camera-mjpg-streamer - -Stream from camera. +# 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. + +[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Ffredrikbaberg%2Fha-3dprinter-addons) + + +## Addons + +### 3DPrinter-OctoPrint + +OctoPrint, plain and simple. + +### 3DPrinter-Remote + +Run OctoPrint on a different machine from the printer. + +### Camera-mjpg-streamer + +Stream from camera. diff --git a/SECURITY.md b/SECURITY.md index 9862d01..3589197 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1 +1 @@ -# Security Policy +# Security Policy diff --git a/camera-mjpg-streamer/CHANGELOG.md b/camera-mjpg-streamer/CHANGELOG.md index 692993b..2de684e 100644 --- a/camera-mjpg-streamer/CHANGELOG.md +++ b/camera-mjpg-streamer/CHANGELOG.md @@ -1,3 +1,3 @@ -## 2024.01.0 - +## 2024.01.0 + * Maintenance release \ No newline at end of file diff --git a/camera-mjpg-streamer/DOCS.md b/camera-mjpg-streamer/DOCS.md index c45cb93..67f5a71 100644 --- a/camera-mjpg-streamer/DOCS.md +++ b/camera-mjpg-streamer/DOCS.md @@ -1,36 +1,36 @@ -# 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:///?action=stream` -* Still image URL: `http:///?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%2Fha-3dprinter-addons). - -## Ingress? - -Ingress support is included only to verify that the camera can be accessed. Streaming will most likely only work in the "JavaScript" tab. - -## Testing - -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). +# 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:///?action=stream` +* Still image URL: `http:///?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%2Fha-3dprinter-addons). + +## Ingress? + +Ingress support is included only to verify that the camera can be accessed. Streaming will most likely only work in the "JavaScript" tab. + +## Testing + +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). diff --git a/camera-mjpg-streamer/Dockerfile b/camera-mjpg-streamer/Dockerfile index 5e207f0..2b56ae9 100644 --- a/camera-mjpg-streamer/Dockerfile +++ b/camera-mjpg-streamer/Dockerfile @@ -1,23 +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/*/* +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/*/* diff --git a/camera-mjpg-streamer/README.md b/camera-mjpg-streamer/README.md index e010b0c..fa9291a 100644 --- a/camera-mjpg-streamer/README.md +++ b/camera-mjpg-streamer/README.md @@ -1,5 +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". +# mjpg-streamer + +Provides camera stream through `mjpg-streamer`, to be used by e.g. OctoPrint addon. + +Instructions are provided in the tab "Docs". diff --git a/camera-mjpg-streamer/config.yaml b/camera-mjpg-streamer/config.yaml index d2fe0d6..e44ec0f 100644 --- a/camera-mjpg-streamer/config.yaml +++ b/camera-mjpg-streamer/config.yaml @@ -1,28 +1,28 @@ -name: "Camera-mjpg-streamer" -version: "2024.01.0" -slug: "camera-mjpg-streamer" -description: "Camera streaming addon for Home Assistant, based on mjpg-streamer." -url: "https://github.com/fredrikbaberg/ha-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/ha-addon-camera-mjpg-streamer-{arch} +name: "Camera-mjpg-streamer" +version: "2024.01.0" +slug: "camera-mjpg-streamer" +description: "Camera streaming addon for Home Assistant, based on mjpg-streamer." +url: "https://github.com/fredrikbaberg/ha-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/ha-addon-camera-mjpg-streamer-{arch} diff --git a/camera-mjpg-streamer/rootfs/etc/cont-init.d/nginx.sh b/camera-mjpg-streamer/rootfs/etc/cont-init.d/nginx.sh index c84e750..d69c2b6 100644 --- a/camera-mjpg-streamer/rootfs/etc/cont-init.d/nginx.sh +++ b/camera-mjpg-streamer/rootfs/etc/cont-init.d/nginx.sh @@ -1,22 +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 +#!/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 diff --git a/camera-mjpg-streamer/rootfs/etc/nginx/includes/mime.types b/camera-mjpg-streamer/rootfs/etc/nginx/includes/mime.types index c230212..7ae7922 100644 --- a/camera-mjpg-streamer/rootfs/etc/nginx/includes/mime.types +++ b/camera-mjpg-streamer/rootfs/etc/nginx/includes/mime.types @@ -1,96 +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; +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; } \ No newline at end of file diff --git a/camera-mjpg-streamer/rootfs/etc/nginx/includes/proxy_params.conf b/camera-mjpg-streamer/rootfs/etc/nginx/includes/proxy_params.conf index 1990d49..cf0823c 100644 --- a/camera-mjpg-streamer/rootfs/etc/nginx/includes/proxy_params.conf +++ b/camera-mjpg-streamer/rootfs/etc/nginx/includes/proxy_params.conf @@ -1,15 +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; +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/camera-mjpg-streamer/rootfs/etc/nginx/includes/server_params.conf b/camera-mjpg-streamer/rootfs/etc/nginx/includes/server_params.conf index 09c0654..7e90e5b 100644 --- a/camera-mjpg-streamer/rootfs/etc/nginx/includes/server_params.conf +++ b/camera-mjpg-streamer/rootfs/etc/nginx/includes/server_params.conf @@ -1,6 +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; +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/camera-mjpg-streamer/rootfs/etc/nginx/includes/ssl_params.conf b/camera-mjpg-streamer/rootfs/etc/nginx/includes/ssl_params.conf index e6789cb..c5b73ba 100644 --- a/camera-mjpg-streamer/rootfs/etc/nginx/includes/ssl_params.conf +++ b/camera-mjpg-streamer/rootfs/etc/nginx/includes/ssl_params.conf @@ -1,8 +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; +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; diff --git a/camera-mjpg-streamer/rootfs/etc/nginx/includes/upstream.conf b/camera-mjpg-streamer/rootfs/etc/nginx/includes/upstream.conf index 6dc04d8..d9818c6 100644 --- a/camera-mjpg-streamer/rootfs/etc/nginx/includes/upstream.conf +++ b/camera-mjpg-streamer/rootfs/etc/nginx/includes/upstream.conf @@ -1,3 +1,3 @@ -upstream backend { - server 127.0.0.1:80; -} +upstream backend { + server 127.0.0.1:80; +} diff --git a/camera-mjpg-streamer/rootfs/etc/nginx/nginx.conf b/camera-mjpg-streamer/rootfs/etc/nginx/nginx.conf index 11e15c7..a879ca2 100644 --- a/camera-mjpg-streamer/rootfs/etc/nginx/nginx.conf +++ b/camera-mjpg-streamer/rootfs/etc/nginx/nginx.conf @@ -1,44 +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; -} +# 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; +} diff --git a/camera-mjpg-streamer/rootfs/etc/nginx/templates/direct.gtpl b/camera-mjpg-streamer/rootfs/etc/nginx/templates/direct.gtpl index 2fd0020..53c2011 100644 --- a/camera-mjpg-streamer/rootfs/etc/nginx/templates/direct.gtpl +++ b/camera-mjpg-streamer/rootfs/etc/nginx/templates/direct.gtpl @@ -1,10 +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; - } -} +server { + listen {{ .port }} default_server; + + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + + location / { + proxy_pass http://backend; + } +} diff --git a/camera-mjpg-streamer/rootfs/etc/nginx/templates/ingress.gtpl b/camera-mjpg-streamer/rootfs/etc/nginx/templates/ingress.gtpl index e216772..990025b 100644 --- a/camera-mjpg-streamer/rootfs/etc/nginx/templates/ingress.gtpl +++ b/camera-mjpg-streamer/rootfs/etc/nginx/templates/ingress.gtpl @@ -1,13 +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; - } -} +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; + } +} diff --git a/camera-mjpg-streamer/rootfs/etc/services.d/mjpg-streamer/finish b/camera-mjpg-streamer/rootfs/etc/services.d/mjpg-streamer/finish index 1ecc5e9..ee3f07b 100644 --- a/camera-mjpg-streamer/rootfs/etc/services.d/mjpg-streamer/finish +++ b/camera-mjpg-streamer/rootfs/etc/services.d/mjpg-streamer/finish @@ -1,9 +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 +#!/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 diff --git a/camera-mjpg-streamer/rootfs/etc/services.d/mjpg-streamer/run b/camera-mjpg-streamer/rootfs/etc/services.d/mjpg-streamer/run index 52f5786..f2d2e5d 100644 --- a/camera-mjpg-streamer/rootfs/etc/services.d/mjpg-streamer/run +++ b/camera-mjpg-streamer/rootfs/etc/services.d/mjpg-streamer/run @@ -1,9 +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" +#!/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" diff --git a/camera-mjpg-streamer/rootfs/etc/services.d/nginx/finish b/camera-mjpg-streamer/rootfs/etc/services.d/nginx/finish index 382feb6..0b93950 100644 --- a/camera-mjpg-streamer/rootfs/etc/services.d/nginx/finish +++ b/camera-mjpg-streamer/rootfs/etc/services.d/nginx/finish @@ -1,9 +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 +#!/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 diff --git a/camera-mjpg-streamer/rootfs/etc/services.d/nginx/run b/camera-mjpg-streamer/rootfs/etc/services.d/nginx/run index fe6cffa..480fe27 100644 --- a/camera-mjpg-streamer/rootfs/etc/services.d/nginx/run +++ b/camera-mjpg-streamer/rootfs/etc/services.d/nginx/run @@ -1,11 +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 +#!/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 diff --git a/repository.yaml b/repository.yaml index 17aae4a..78469f8 100644 --- a/repository.yaml +++ b/repository.yaml @@ -1,3 +1,3 @@ -name: 3DPrinter addons for Home-Asssistant by fredrikbaberg -url: https://github.com/fredrikbaberg/ha-3dprinter-addons -maintainer: Fredrik Baberg +name: 3DPrinter addons for Home-Asssistant by fredrikbaberg +url: https://github.com/fredrikbaberg/ha-3dprinter-addons +maintainer: Fredrik Baberg