From f8b79f0232f16b85d3ccb46fa06d965681312b04 Mon Sep 17 00:00:00 2001 From: Ferdinand99 Date: Sat, 8 Mar 2025 19:17:31 +0100 Subject: [PATCH] Upload files to "newt" --- newt/Dockerfile | 16 ++++++++++++++++ newt/config.yaml | 31 +++++++++++++++++++++++++++++++ newt/run.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 newt/Dockerfile create mode 100644 newt/config.yaml create mode 100644 newt/run.sh diff --git a/newt/Dockerfile b/newt/Dockerfile new file mode 100644 index 0000000..7994692 --- /dev/null +++ b/newt/Dockerfile @@ -0,0 +1,16 @@ +# Use the official Home Assistant add-on base image +FROM ghcr.io/hassio-addons/base:14.0.0 + +# Install dependencies +RUN apk add --no-cache bash curl jq + +# Download and install Newt +RUN curl -fsSL -o /usr/bin/newt https://github.com/fosrl/newt/releases/download/1.0.0/newt_linux_amd64 \ + && chmod +x /usr/bin/newt + +# Copy the script into the container +COPY run.sh /run.sh +RUN chmod +x /run.sh + +# Run the script as the main process +ENTRYPOINT [ "/run.sh" ] diff --git a/newt/config.yaml b/newt/config.yaml new file mode 100644 index 0000000..1f67ace --- /dev/null +++ b/newt/config.yaml @@ -0,0 +1,31 @@ +name: "Newt Add-on" +version: "1.2.3" +slug: "newt" +description: "Runs Newt inside Home Assistant OS" +arch: + - amd64 + - armv7 + - armhf + - aarch64 +startup: system +boot: auto +host_network: true +privileged: + - SYS_ADMIN + - NET_ADMIN + - DAC_READ_SEARCH +options: + PANGOLIN_ENDPOINT: "https://example.com" + NEWT_ID: "your_newt_id" + NEWT_SECRET: "your_newt_secret" +schema: + PANGOLIN_ENDPOINT: "str" + NEWT_ID: "str" + NEWT_SECRET: "str" +# Ensure that environment variables are set correctly +map: + - config:rw +hassio_api: true +homeassistant_api: true +auth_api: true +hassio_role: "admin" \ No newline at end of file diff --git a/newt/run.sh b/newt/run.sh new file mode 100644 index 0000000..e5249ec --- /dev/null +++ b/newt/run.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -e # Stop the script on errors + +echo "🔹 Starting Newt inside Home Assistant OS..." + +# Load configuration manually from the add-on options JSON file +CONFIG_PATH="/data/options.json" + +if [[ ! -f "$CONFIG_PATH" ]]; then + echo "❌ ERROR: Configuration file not found at $CONFIG_PATH!" + exit 1 +fi + +# Extract values from the JSON config +PANGOLIN_ENDPOINT=$(jq -r '.PANGOLIN_ENDPOINT' "$CONFIG_PATH") +NEWT_ID=$(jq -r '.NEWT_ID' "$CONFIG_PATH") +NEWT_SECRET=$(jq -r '.NEWT_SECRET' "$CONFIG_PATH") + +# Validate if configuration values are provided +if [[ -z "$PANGOLIN_ENDPOINT" || -z "$NEWT_ID" || -z "$NEWT_SECRET" || "$PANGOLIN_ENDPOINT" == "null" ]]; then + echo "❌ ERROR: Missing required configuration values!" + exit 1 +fi + +echo "✅ Configuration Loaded:" +echo " PANGOLIN_ENDPOINT=$PANGOLIN_ENDPOINT" +echo " NEWT_ID=$NEWT_ID" +echo " NEWT_SECRET=$NEWT_SECRET" + +# Run Newt inside the add-on container using environment variables +echo "🔹 Running Newt..." +PANGOLIN_ENDPOINT="$PANGOLIN_ENDPOINT" NEWT_ID="$NEWT_ID" NEWT_SECRET="$NEWT_SECRET" /usr/bin/newt & + +echo "✅ Newt is running!" +exec tail -f /dev/null # Keep the add-on running