Add docker-cli installation to Dockerfile and streamline WOL script
This commit is contained in:
@@ -4,7 +4,7 @@ FROM alpine:3.20
|
|||||||
# Install minimal tooling
|
# Install minimal tooling
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing wol \
|
--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
|
# Copy script
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -27,28 +27,22 @@ send_wol() {
|
|||||||
wol -i "$WOL_BCAST" -p "$WOL_PORT" "$WOL_MAC" || true
|
wol -i "$WOL_BCAST" -p "$WOL_PORT" "$WOL_MAC" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Basic pre-flight: show which container is watched
|
# Basic pre-flight: show which container is watched
|
||||||
log "Watching logs for container='${CONTAINER_NAME}' since='${SINCE}'"
|
log "Watching logs for container='${CONTAINER_NAME}' since='${SINCE}'"
|
||||||
log "Looking for pattern: ${ERROR_PATTERN}"
|
log "Looking for pattern: ${ERROR_PATTERN}"
|
||||||
|
|
||||||
echo "Exited. Sleeping..."
|
|
||||||
sleep infinity
|
|
||||||
|
|
||||||
# Stream logs and parse
|
# Stream logs and parse
|
||||||
"${DOCKER_CLI}" logs -f --since "${SINCE}" "${CONTAINER_NAME}" 2>&1 | \
|
"${DOCKER_CLI}" logs -f --since "${SINCE}" "${CONTAINER_NAME}" 2>&1 | \
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
# echo "$line" # uncomment for debugging
|
# echo "$line" # uncomment for debugging
|
||||||
if echo "$line" | grep -qE "${ERROR_PATTERN}"; then
|
if echo "$line" | grep -qE "${ERROR_PATTERN}"; then
|
||||||
log "Detected EHOSTUNREACH for Ollama (${OLLAMA_HOST}:${OLLAMA_PORT})."
|
log "Detected EHOSTUNREACH for Ollama (${OLLAMA_HOST}:${OLLAMA_PORT})."
|
||||||
echo ok
|
|
||||||
|
|
||||||
# ... in your remediation block:
|
# ... in your remediation block:
|
||||||
if [[ -n "$WOL_MAC" ]]; then
|
if [[ -n "$WOL_MAC" ]]; then
|
||||||
log "Sending WOL to $WOL_MAC via ${WOL_BCAST}:${WOL_PORT}"
|
log "Sending WOL to $WOL_MAC via ${WOL_BCAST}:${WOL_PORT}"
|
||||||
#send_wol
|
send_wol
|
||||||
fi
|
fi
|
||||||
echo ok
|
|
||||||
# --- remediation examples (optional) ---
|
# --- remediation examples (optional) ---
|
||||||
# if [[ -n "$WOL_MAC" ]]; then
|
# if [[ -n "$WOL_MAC" ]]; then
|
||||||
# log "Sending WOL to ${WOL_MAC}"
|
# log "Sending WOL to ${WOL_MAC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user