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 0000000..9222efd Binary files /dev/null and b/3dprinter-octoprint/icon.png differ diff --git a/3dprinter-octoprint/logo.png b/3dprinter-octoprint/logo.png new file mode 100644 index 0000000..459e1f2 Binary files /dev/null and b/3dprinter-octoprint/logo.png differ 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