diff --git a/newt/Dockerfile b/newt/Dockerfile index f619972..e0ccf0c 100644 --- a/newt/Dockerfile +++ b/newt/Dockerfile @@ -1,10 +1,9 @@ +# 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 docker-cli - -# Copy the run script +# Copy the script into the container COPY run.sh /run.sh RUN chmod +x /run.sh -CMD [ "/run.sh" ] +# Run the script as the main process +CMD [ "/run.sh" ] \ No newline at end of file diff --git a/newt/run.sh b/newt/run.sh index 002b9ab..9834f04 100644 --- a/newt/run.sh +++ b/newt/run.sh @@ -1,26 +1,26 @@ #!/usr/bin/env bash set -e -echo "Starter Newt container..." +echo "Starting Newt container..." -# Hent verdier fra Home Assistant config +# Load config from Home Assistant options PANGOLIN_ENDPOINT=$(bashio::config 'PANGOLIN_ENDPOINT') NEWT_ID=$(bashio::config 'NEWT_ID') NEWT_SECRET=$(bashio::config 'NEWT_SECRET') -# Sjekk at Docker kjører +# Ensure Docker is running if ! docker info >/dev/null 2>&1; then - echo "Docker er ikke tilgjengelig i Home Assistant OS!" + echo "Docker is not available inside Home Assistant OS!" exit 1 fi -# Stopp og fjern gammel container hvis den finnes +# Stop and remove any existing Newt container if docker ps -a --format '{{.Names}}' | grep -q "newt"; then docker stop newt docker rm newt fi -# Kjør Newt-containeren +# Run Newt container docker run -d --restart unless-stopped \ --name newt \ -e PANGOLIN_ENDPOINT="$PANGOLIN_ENDPOINT" \ @@ -28,5 +28,7 @@ docker run -d --restart unless-stopped \ -e NEWT_SECRET="$NEWT_SECRET" \ fosrl/newt -echo "Newt-container kjører!" +echo "Newt container is running!" + +# Prevent the script from exiting (keeps the add-on running) exec tail -f /dev/null