From 8ee2aff40cff249d414401b63f92720da9911a70 Mon Sep 17 00:00:00 2001 From: Carlo Costanzo Date: Fri, 5 Dec 2025 00:10:41 -0500 Subject: [PATCH] Switching all configurations to happen via Codex Agents and n8n. Refactor HAUpdate.sh to use 'docker compose' syntax for improved compatibility and readability. Added error handling with 'set -euo pipefail' and removed unused resource cleanup commands. --- config/shell_scripts/HAUpdate.sh | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/config/shell_scripts/HAUpdate.sh b/config/shell_scripts/HAUpdate.sh index 374a324a..0ff9182d 100755 --- a/config/shell_scripts/HAUpdate.sh +++ b/config/shell_scripts/HAUpdate.sh @@ -1,23 +1,26 @@ # - This script is used to update the Home Assistant Docker containers # - It will pull the latest images, check if the image ID has changed, and restart the container if needed -# - It will also cleanup unused resources after the update # Original Repo: https://github.com/CCOSTAN/Home-AssistantConfig # Follow me on https://www.vcloudinfo.com/click-here #!/bin/bash +set -euo pipefail + # Update system packages sudo apt-get update && sudo apt-get upgrade -y +DC=(docker compose) + # Pull the latest images -docker-compose pull +"${DC[@]}" pull # Get list of services from docker-compose.yml -EXISTING_SERVICES=$(docker-compose config --services) +EXISTING_SERVICES=$("${DC[@]}" config --services) # Get list of running service containers -RUNNING_CONTAINERS=$(docker-compose ps --services) +RUNNING_CONTAINERS=$("${DC[@]}" ps --services) # Loop through each running service and check if its image has changed for service in $RUNNING_CONTAINERS; do @@ -25,15 +28,15 @@ for service in $RUNNING_CONTAINERS; do # Get the current running image ID (remove sha256: prefix) CURRENT_IMAGE_ID=$(docker inspect --format='{{.Image}}' "$service" 2>/dev/null | sed 's/^sha256://') - # Get the latest image ID from docker-compose - LATEST_IMAGE_ID=$(docker-compose images -q "$service" 2>/dev/null) + # Get the latest image ID from docker compose + LATEST_IMAGE_ID=$("${DC[@]}" images -q "$service" 2>/dev/null) # If the image ID is different, restart the container if [ "$CURRENT_IMAGE_ID" != "$LATEST_IMAGE_ID" ] && [ -n "$LATEST_IMAGE_ID" ]; then echo "Updating container: $service" - docker-compose stop "$service" - docker-compose rm -f "$service" - docker-compose up -d "$service" + "${DC[@]}" stop "$service" + "${DC[@]}" rm -f "$service" + "${DC[@]}" up -d "$service" else echo "No update needed for: $service" fi @@ -41,8 +44,3 @@ for service in $RUNNING_CONTAINERS; do echo "Skipping non-existent service: $service" fi done - -# Cleanup unused resources -docker container prune -f -docker image prune -f -docker volume prune -f