Updated scripts and versions. Also adding in UI Yaml to help everyone. removed CACHE from TTS,

This commit is contained in:
CCOSTAN
2025-03-04 18:17:35 +00:00
parent bcee75652d
commit 4caff5def4
7 changed files with 180 additions and 38 deletions

View File

@@ -1,18 +1,48 @@
# ## These scripts are run from /home/pi
#
# #!/bin/bash
#
# cd /home/hass/.homeassistant
# source /srv/hass/hass_venv/bin/activate
#
# echo "Processing update"
# pip3 install --upgrade homeassistant
#
# hass --script check_config
# exit
# - 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
cd /home/hass/docker_files
docker-compose down
# Update system packages
sudo apt-get update && sudo apt-get upgrade -y
# Pull the latest images
docker-compose pull
docker-compose up -d
# Get list of services from docker-compose.yml
EXISTING_SERVICES=$(docker-compose config --services)
# Get list of running service containers
RUNNING_CONTAINERS=$(docker-compose ps --services)
# Loop through each running service and check if its image has changed
for service in $RUNNING_CONTAINERS; do
if echo "$EXISTING_SERVICES" | grep -qw "$service"; then
# 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)
# 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"
else
echo "No update needed for: $service"
fi
else
echo "Skipping non-existent service: $service"
fi
done
# Cleanup unused resources
docker container prune -f
docker image prune -f
docker volume prune -f