Upload files to "newt"
This commit is contained in:
commit
f8b79f0232
3 changed files with 82 additions and 0 deletions
16
newt/Dockerfile
Normal file
16
newt/Dockerfile
Normal file
|
@ -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" ]
|
31
newt/config.yaml
Normal file
31
newt/config.yaml
Normal file
|
@ -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"
|
35
newt/run.sh
Normal file
35
newt/run.sh
Normal file
|
@ -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
|
Loading…
Reference in a new issue