Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Supervisor image corruption detection #2953

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions buildroot-external/rootfs-overlay/usr/sbin/hassos-supervisor
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,20 @@ if [ -f "${SUPERVISOR_STARTUP_MARKER}" ]; then
echo "[WARNING] Supervisor container did not remove the startup marker file. Assuming container image or container corruption."
docker container rm --force hassio_supervisor || true
SUPERVISOR_CONTAINER_ID=""

# Make sure we delete all supervisor images
SUPERVISOR_IMAGE_IDS=$(docker images --no-trunc --filter "reference=${SUPERVISOR_IMAGE}" --format "{{.ID}}" | uniq || echo "")
docker image rm --force "${SUPERVISOR_IMAGE_IDS}" || true
SUPERVISOR_IMAGE_IDS=$(docker images --no-trunc --filter "reference=${SUPERVISOR_IMAGE}" --format "{{.ID}}" | sort | uniq || echo "")
# Intended splitting of SUPERVISOR_IMAGE_IDS
# Busybox sh doesn't support arrays
# shellcheck disable=SC2086
docker image rm --force ${SUPERVISOR_IMAGE_IDS} || true
SUPERVISOR_IMAGE_ID=""
fi

# If Supervisor image is missing, pull it
mkdir -p "$(dirname ${SUPERVISOR_STARTUP_MARKER})"
touch ${SUPERVISOR_STARTUP_MARKER}
if [ -z "${SUPERVISOR_IMAGE_ID}" ]; then
# Try tagging legacy image with current name and try get its ID
echo "[WARNING] Supervisor image missing, trying to use the legacy image name"
docker tag "homeassistant/${SUPERVISOR_ARCH}-hassio-supervisor:latest" "${SUPERVISOR_IMAGE}:latest" || true
SUPERVISOR_IMAGE_ID=$(docker images --no-trunc --filter "reference=${SUPERVISOR_IMAGE}:latest" --format "{{.ID}}" || echo "")
fi

# If Supervisor image is missing, pull it
if [ -z "${SUPERVISOR_IMAGE_ID}" ]; then
# Get the latest from update information
# Using updater information instead of config. If the config version is
Expand Down
Loading