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,35 +1,34 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e # Stop the script on errors set -e
echo "🔹 Starting Newt inside Home Assistant OS..." echo "🔹 Starting Newt inside Home Assistant OS..."
# Load configuration manually from the add-on options JSON file CONFIG_PATH="/data/options.json"
CONFIG_PATH="/data/options.json"
if [[ ! -f "$CONFIG_PATH" ]]; then
if [[ ! -f "$CONFIG_PATH" ]]; then echo "❌ ERROR: Configuration file not found at $CONFIG_PATH!"
echo "❌ ERROR: Configuration file not found at $CONFIG_PATH!" exit 1
exit 1 fi
fi
PANGOLIN_ENDPOINT=$(jq -r '.PANGOLIN_ENDPOINT' "$CONFIG_PATH")
# Extract values from the JSON config NEWT_ID=$(jq -r '.NEWT_ID' "$CONFIG_PATH")
PANGOLIN_ENDPOINT=$(jq -r '.PANGOLIN_ENDPOINT' "$CONFIG_PATH") NEWT_SECRET=$(jq -r '.NEWT_SECRET' "$CONFIG_PATH")
NEWT_ID=$(jq -r '.NEWT_ID' "$CONFIG_PATH")
NEWT_SECRET=$(jq -r '.NEWT_SECRET' "$CONFIG_PATH") if [[ -z "$PANGOLIN_ENDPOINT" || -z "$NEWT_ID" || -z "$NEWT_SECRET" || "$PANGOLIN_ENDPOINT" == "null" ]]; then
echo "❌ ERROR: Missing required configuration values!"
# Validate if configuration values are provided exit 1
if [[ -z "$PANGOLIN_ENDPOINT" || -z "$NEWT_ID" || -z "$NEWT_SECRET" || "$PANGOLIN_ENDPOINT" == "null" ]]; then fi
echo "❌ ERROR: Missing required configuration values!"
exit 1 echo "✅ Configuration Loaded:"
fi echo " PANGOLIN_ENDPOINT=$PANGOLIN_ENDPOINT"
echo " NEWT_ID=$NEWT_ID"
echo "✅ Configuration Loaded:" echo " NEWT_SECRET=$NEWT_SECRET"
echo " PANGOLIN_ENDPOINT=$PANGOLIN_ENDPOINT"
echo " NEWT_ID=$NEWT_ID" # 🔁 Auto-reconnect loop
echo " NEWT_SECRET=$NEWT_SECRET" while true; do
echo "🔹 Starting Newt..."
# Run Newt inside the add-on container using environment variables PANGOLIN_ENDPOINT="$PANGOLIN_ENDPOINT" NEWT_ID="$NEWT_ID" NEWT_SECRET="$NEWT_SECRET" /usr/bin/newt
echo "🔹 Running Newt..."
PANGOLIN_ENDPOINT="$PANGOLIN_ENDPOINT" NEWT_ID="$NEWT_ID" NEWT_SECRET="$NEWT_SECRET" /usr/bin/newt & echo "⚠️ Newt stopped! Waiting 5 second before reconnecting..."
sleep 5
echo "✅ Newt is running!" done
exec tail -f /dev/null # Keep the add-on running