Fix: Run Newt container directly in Home Assistant OS - v1.1.7
This commit is contained in:
parent
34ba54aa97
commit
c4b7f4da90
2 changed files with 29 additions and 30 deletions
57
newt/run.sh
57
newt/run.sh
|
@ -1,41 +1,40 @@
|
|||
#!/usr/bin/env bash
|
||||
source /usr/lib/bashio/bashio.sh
|
||||
set -e # Stop the script on errors
|
||||
|
||||
set -e # Stop script on errors
|
||||
echo "🔹 Starting Newt container using Home Assistant OS..."
|
||||
|
||||
echo "🔹 Starting Newt container using Home Assistant Supervisor API..."
|
||||
|
||||
# Load config from Home Assistant options
|
||||
PANGOLIN_ENDPOINT=${PANGOLIN_ENDPOINT:-"https://eample.com"}
|
||||
NEWT_ID=${NEWT_ID:-"123456789"}
|
||||
NEWT_SECRET=${NEWT_SECRET:-"waytolongsecret"}
|
||||
|
||||
|
||||
if [[ -z "$PANGOLIN_ENDPOINT" || -z "$NEWT_ID" || -z "$NEWT_SECRET" ]]; then
|
||||
echo "❌ ERROR: Missing configuration values!"
|
||||
# Check if Docker is available
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "❌ ERROR: Docker is NOT available inside Home Assistant OS!"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Docker is available!"
|
||||
|
||||
echo "✅ Configuration Loaded:"
|
||||
# Retrieve environment variables
|
||||
PANGOLIN_ENDPOINT=${PANGOLIN_ENDPOINT:-"https://dash.opland.net"}
|
||||
NEWT_ID=${NEWT_ID:-"ru32vsg8ls5lx93"}
|
||||
NEWT_SECRET=${NEWT_SECRET:-"5rbqgpc292989uk9kz52hmypoyz6u9jf7k670fqja8p4un8o"}
|
||||
|
||||
echo "🔹 Environment Variables:"
|
||||
echo " PANGOLIN_ENDPOINT=$PANGOLIN_ENDPOINT"
|
||||
echo " NEWT_ID=$NEWT_ID"
|
||||
echo " NEWT_SECRET=$NEWT_SECRET"
|
||||
|
||||
# Use Home Assistant Supervisor API to run the Newt container
|
||||
echo "🔹 Creating and starting Newt container via Supervisor API..."
|
||||
curl --silent --fail --header "Authorization: Bearer ${SUPERVISOR_TOKEN}" \
|
||||
-X POST "http://supervisor/docker/containers/run" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"name": "newt",
|
||||
"image": "fosrl/newt",
|
||||
"restart_policy": "unless-stopped",
|
||||
"env": [
|
||||
"PANGOLIN_ENDPOINT='"$PANGOLIN_ENDPOINT"'",
|
||||
"NEWT_ID='"$NEWT_ID"'",
|
||||
"NEWT_SECRET='"$NEWT_SECRET"'"
|
||||
]
|
||||
}' || { echo "❌ ERROR: Failed to start Newt container via Supervisor API"; exit 22; }
|
||||
# Remove old Newt container if it exists
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "newt"; then
|
||||
echo "🔹 Stopping and removing existing Newt container..."
|
||||
docker stop newt
|
||||
docker rm newt
|
||||
fi
|
||||
|
||||
# Run the Newt container
|
||||
echo "🔹 Starting Newt container..."
|
||||
docker run -d --restart unless-stopped \
|
||||
--name newt \
|
||||
-e PANGOLIN_ENDPOINT="$PANGOLIN_ENDPOINT" \
|
||||
-e NEWT_ID="$NEWT_ID" \
|
||||
-e NEWT_SECRET="$NEWT_SECRET" \
|
||||
fosrl/newt || { echo "❌ ERROR: Failed to start Newt container"; exit 22; }
|
||||
|
||||
echo "✅ Newt container started successfully!"
|
||||
exec tail -f /dev/null
|
||||
exec tail -f /dev/null # Keep the add-on running
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue