From 45ddc791b54fa7ee1511ae8476605218a52a62a0 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 27 Jun 2022 00:30:50 +0200 Subject: [PATCH] Add test version of 3DPrinter-OctoPrint --- 3dprinter-octoprint/CHANGELOG.md | 0 3dprinter-octoprint/DOCS.md | 0 3dprinter-octoprint/Dockerfile | 22 +++++++ 3dprinter-octoprint/README.md | 0 3dprinter-octoprint/apparmor.txt | 57 ++++++++++++++++++ 3dprinter-octoprint/build.yaml | 12 ++++ 3dprinter-octoprint/config.yaml | 20 ++++++ 3dprinter-octoprint/icon.png | Bin 0 -> 49206 bytes 3dprinter-octoprint/logo.png | Bin 0 -> 75254 bytes .../rootfs/etc/cont-init.d/octoprint.sh | 16 +++++ .../rootfs/etc/services.d/octoprint/finish | 12 ++++ .../rootfs/etc/services.d/octoprint/run | 8 +++ 3dprinter-octoprint/translations/en.yaml | 4 ++ README.md | 13 ++++ repository.yaml | 3 + 15 files changed, 167 insertions(+) create mode 100644 3dprinter-octoprint/CHANGELOG.md create mode 100644 3dprinter-octoprint/DOCS.md create mode 100644 3dprinter-octoprint/Dockerfile create mode 100644 3dprinter-octoprint/README.md create mode 100644 3dprinter-octoprint/apparmor.txt create mode 100644 3dprinter-octoprint/build.yaml create mode 100644 3dprinter-octoprint/config.yaml create mode 100644 3dprinter-octoprint/icon.png create mode 100644 3dprinter-octoprint/logo.png create mode 100644 3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh create mode 100644 3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish create mode 100644 3dprinter-octoprint/rootfs/etc/services.d/octoprint/run create mode 100644 3dprinter-octoprint/translations/en.yaml create mode 100644 repository.yaml diff --git a/3dprinter-octoprint/CHANGELOG.md b/3dprinter-octoprint/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/3dprinter-octoprint/DOCS.md b/3dprinter-octoprint/DOCS.md new file mode 100644 index 0000000..e69de29 diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile new file mode 100644 index 0000000..bb5f260 --- /dev/null +++ b/3dprinter-octoprint/Dockerfile @@ -0,0 +1,22 @@ +ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" +FROM ${BUILD_FROM} +ARG OCTOPRINT_VERSION="1.8.1" + +ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} + +# Setup path for persistent install of Python packages +ENV PYTHONPATH=/data/python/octoprint +ENV PYTHONUSERBASE=/data/python/octoprint +ENV PATH=${PATH}:/data/python/octoprint/bin + +# Install dependencies +RUN apt update && \ + apt install -y \ + python3-venv \ + python3-dev \ + build-essential \ + && \ + apt clean + +# Copy root filesystem +COPY rootfs / diff --git a/3dprinter-octoprint/README.md b/3dprinter-octoprint/README.md new file mode 100644 index 0000000..e69de29 diff --git a/3dprinter-octoprint/apparmor.txt b/3dprinter-octoprint/apparmor.txt new file mode 100644 index 0000000..9522719 --- /dev/null +++ b/3dprinter-octoprint/apparmor.txt @@ -0,0 +1,57 @@ +#include + +profile example 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/my_program cx -> my_program, + + profile my_program flags=(attach_disconnected,mediate_deleted) { + #include + + # Receive signals from S6-Overlay + signal (receive) peer=*_example, + + # Access to options.json and other files within your addon + /data/** rw, + + # Access to mapped volumes specified in config.json + /share/** rw, + + # Access required for service functionality + # Note: List was built by doing the following: + # 1. Add what is obviously needed based on what is in the script + # 2. Add `complain` as a flag to this profile temporarily and run the addon + # 3. Review the audit log with `journalctl _TRANSPORT="audit" -g 'apparmor="ALLOWED"'` and add other access as needed + # Remember to remove the `complain` flag when you are done + # /usr/bin/my_program r, + /bin/bash rix, + /bin/echo ix, + /etc/passwd r, + /dev/tty rw, + } +} \ No newline at end of file diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml new file mode 100644 index 0000000..72fafe9 --- /dev/null +++ b/3dprinter-octoprint/build.yaml @@ -0,0 +1,12 @@ +build_from: + aarch64: ghcr.io/home-assistant/aarch64-base-debian:bullseye + amd64: ghcr.io/home-assistant/amd64-base-debian:bullseye + armhf: ghcr.io/home-assistant/armhf-base-debian:bullseye + armv7: ghcr.io/home-assistant/armv7-base-debian:bullseye + i386: ghcr.io/home-assistant/i386-base-debian:bullseye +labels: + org.opencontainers.image.title: "Home Assistant Add-on: 3DPrinter-OctoPrint add-on" + org.opencontainers.image.description: "3DPrinter-OctoPrint addon for Home-Assistant." + org.opencontainers.image.source: "https://github.com/fredrikbaberg/home-assistant-addons" +args: + OCTOPRINT_VERSION: "1.8.1" diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml new file mode 100644 index 0000000..3818a8e --- /dev/null +++ b/3dprinter-octoprint/config.yaml @@ -0,0 +1,20 @@ +name: "3DPrinter-OctoPrint" +version: "2022.6.010" +slug: "3dprinter-octoprint" +description: "Instance of OctoPrint" +url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" +arch: + - aarch64 + - amd64 + - armhf + - armv7 + - i386 +init: false +map: + - share:rw +options: + message: "Hello world..." +schema: + message: "str?" +ports: + 5000/tcp: null diff --git a/3dprinter-octoprint/icon.png b/3dprinter-octoprint/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9222efd99e2dde507055e24f60d2c44c679c5a3b GIT binary patch literal 49206 zcmeI$(M=pd5Jgd(g+p)z1mJ(?UKwjOQ!9;z=jj7R4+%64TYYQK{_*|C^UKqp zujkv(Z@2HCf4{#xeZ4*1zFz+P-2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TekgGLw^xDhIGf!z`IR>9VN$5A5_4WZGY9!Uql~-=tfh6cbft?N-11zC}7LBu7>{3 z8}i_iGX=oAO#x?V?=~D;w*A#~9Z|Q*?=W!iZd0H`G+c&^Y`aV=f~qJ0-Ydeu>{0>n z?lP?is-ggRuLuLPO9jBY%d{e>iUQ!hA`Hwf6#(xp(~6)f3V`>DFfhAR0KB_QD}t&h d0NyLY!0b{1@a{6L2&$q0c&`Wpvr7er;a^Ppy?6is literal 0 HcmV?d00001 diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh new file mode 100644 index 0000000..0fa3d9f --- /dev/null +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -0,0 +1,16 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Prepare OctoPrint +# s6-overlay docs: https://github.com/just-containers/s6-overlay +# ============================================================================== + +{ # Check if OctoPrint is installed + octoprint --version +} || { # Otherwise install + { # Check if Python is available + python --version + } || { # Otherwise install + python3 -m venv /data/python/octoprint + } + pip install octoprint==$OCTOPRINT_VERSION +} \ 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 new file mode 100644 index 0000000..b03a9cf --- /dev/null +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish @@ -0,0 +1,12 @@ +#!/usr/bin/env bashio +# ============================================================================== +# Take down the S6 supervision tree when example fails +# s6-overlay docs: https://github.com/just-containers/s6-overlay +# ============================================================================== + +if [[ "$1" -ne 0 ]] && [[ "$1" -ne 256 ]]; then + bashio::log.warning "Halt add-on" + exec /run/s6/basedir/bin/halt +fi + +bashio::log.info "Service restart after closing" diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run new file mode 100644 index 0000000..3add3f7 --- /dev/null +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run @@ -0,0 +1,8 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Start OctoPrint +# s6-overlay docs: https://github.com/just-containers/s6-overlay +# ============================================================================== + +## Run your program +exec octoprint serve --iknowwhatimdoing --host 0.0.0.0 --port 5000 --basedir /data/config/octoprint diff --git a/3dprinter-octoprint/translations/en.yaml b/3dprinter-octoprint/translations/en.yaml new file mode 100644 index 0000000..70de024 --- /dev/null +++ b/3dprinter-octoprint/translations/en.yaml @@ -0,0 +1,4 @@ +configuration: + message: + name: Message + description: The message that will be printed to the log when starting this example add-on. diff --git a/README.md b/README.md index 91cf8c9..422bc0d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # home-assistant-addons Addons for Home Assistant. + +## 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%2Fhome-assistant-addons) + + +## Addons + +### 3DPrinter-OctoPrint + +Addon with OctoPrint \ No newline at end of file diff --git a/repository.yaml b/repository.yaml new file mode 100644 index 0000000..c172374 --- /dev/null +++ b/repository.yaml @@ -0,0 +1,3 @@ +name: fredrikbaberg Home-Asssistant addons +url: https://github.com/fredrikbaberg/home-assistant-addons +maintainer: Fredrik Baberg