Update newt/run.sh

Updated to match GitHub Repo
This commit is contained in:
Jørgen O. 2025-05-02 00:23:56 +02:00
parent 0c1a8dbbac
commit 23e647a8db

View file

@ -1,9 +1,8 @@
#!/usr/bin/env bash
set -e # Stop the script on errors
set -e
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
@ -11,12 +10,10 @@ if [[ ! -f "$CONFIG_PATH" ]]; then
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
@ -27,9 +24,11 @@ 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 &
# 🔁 Auto-reconnect loop
while true; do
echo "🔹 Starting 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
echo "⚠️ Newt stopped! Waiting 5 second before reconnecting..."
sleep 5
done