Add docker-cli installation to Dockerfile and streamline WOL script

This commit is contained in:
Bastian (BaM)
2025-09-13 20:02:34 +02:00
parent 8bfc28dc83
commit 8ecf2a2639
2 changed files with 2 additions and 8 deletions

View File

@@ -4,7 +4,7 @@ FROM alpine:3.20
# Install minimal tooling
RUN apk add --no-cache \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing wol \
&& apk add --no-cache bash curl ca-certificates
&& apk add --no-cache bash curl ca-certificates docker-cli
# Copy script
WORKDIR /app

View File

@@ -27,28 +27,22 @@ send_wol() {
wol -i "$WOL_BCAST" -p "$WOL_PORT" "$WOL_MAC" || true
}
# Basic pre-flight: show which container is watched
log "Watching logs for container='${CONTAINER_NAME}' since='${SINCE}'"
log "Looking for pattern: ${ERROR_PATTERN}"
echo "Exited. Sleeping..."
sleep infinity
# Stream logs and parse
"${DOCKER_CLI}" logs -f --since "${SINCE}" "${CONTAINER_NAME}" 2>&1 | \
while IFS= read -r line; do
# echo "$line" # uncomment for debugging
if echo "$line" | grep -qE "${ERROR_PATTERN}"; then
log "Detected EHOSTUNREACH for Ollama (${OLLAMA_HOST}:${OLLAMA_PORT})."
echo ok
# ... in your remediation block:
if [[ -n "$WOL_MAC" ]]; then
log "Sending WOL to $WOL_MAC via ${WOL_BCAST}:${WOL_PORT}"
#send_wol
send_wol
fi
echo ok
# --- remediation examples (optional) ---
# if [[ -n "$WOL_MAC" ]]; then
# log "Sending WOL to ${WOL_MAC}"