mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-12-12 10:02:18 +00:00
Compare commits
2 Commits
c62e778028
...
44ff4528f1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44ff4528f1 | ||
|
|
8ee2aff40c |
@@ -1,23 +1,26 @@
|
|||||||
# - This script is used to update the Home Assistant Docker containers
|
# - 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 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
|
# Original Repo: https://github.com/CCOSTAN/Home-AssistantConfig
|
||||||
# Follow me on https://www.vcloudinfo.com/click-here
|
# Follow me on https://www.vcloudinfo.com/click-here
|
||||||
|
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
# Update system packages
|
# Update system packages
|
||||||
sudo apt-get update && sudo apt-get upgrade -y
|
sudo apt-get update && sudo apt-get upgrade -y
|
||||||
|
|
||||||
|
DC=(docker compose)
|
||||||
|
|
||||||
# Pull the latest images
|
# Pull the latest images
|
||||||
docker-compose pull
|
"${DC[@]}" pull
|
||||||
|
|
||||||
# Get list of services from docker-compose.yml
|
# 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
|
# 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
|
# Loop through each running service and check if its image has changed
|
||||||
for service in $RUNNING_CONTAINERS; do
|
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)
|
# Get the current running image ID (remove sha256: prefix)
|
||||||
CURRENT_IMAGE_ID=$(docker inspect --format='{{.Image}}' "$service" 2>/dev/null | sed 's/^sha256://')
|
CURRENT_IMAGE_ID=$(docker inspect --format='{{.Image}}' "$service" 2>/dev/null | sed 's/^sha256://')
|
||||||
|
|
||||||
# Get the latest image ID from docker-compose
|
# Get the latest image ID from docker compose
|
||||||
LATEST_IMAGE_ID=$(docker-compose images -q "$service" 2>/dev/null)
|
LATEST_IMAGE_ID=$("${DC[@]}" images -q "$service" 2>/dev/null)
|
||||||
|
|
||||||
# If the image ID is different, restart the container
|
# If the image ID is different, restart the container
|
||||||
if [ "$CURRENT_IMAGE_ID" != "$LATEST_IMAGE_ID" ] && [ -n "$LATEST_IMAGE_ID" ]; then
|
if [ "$CURRENT_IMAGE_ID" != "$LATEST_IMAGE_ID" ] && [ -n "$LATEST_IMAGE_ID" ]; then
|
||||||
echo "Updating container: $service"
|
echo "Updating container: $service"
|
||||||
docker-compose stop "$service"
|
"${DC[@]}" stop "$service"
|
||||||
docker-compose rm -f "$service"
|
"${DC[@]}" rm -f "$service"
|
||||||
docker-compose up -d "$service"
|
"${DC[@]}" up -d "$service"
|
||||||
else
|
else
|
||||||
echo "No update needed for: $service"
|
echo "No update needed for: $service"
|
||||||
fi
|
fi
|
||||||
@@ -41,8 +44,3 @@ for service in $RUNNING_CONTAINERS; do
|
|||||||
echo "Skipping non-existent service: $service"
|
echo "Skipping non-existent service: $service"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Cleanup unused resources
|
|
||||||
docker container prune -f
|
|
||||||
docker image prune -f
|
|
||||||
docker volume prune -f
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<svg width="68.5" height="20" viewBox="0 0 685 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="2025.12.0">
|
<svg width="68.5" height="20" viewBox="0 0 685 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="2025.12.0">
|
||||||
<title>2025.12.0</title>
|
<title>2025.12.0</title>
|
||||||
<linearGradient id="PUIvu" x2="0" y2="100%">
|
<linearGradient id="fJMLg" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
<mask id="PVVTg"><rect width="685" height="200" rx="30" fill="#FFF"/></mask>
|
<mask id="uYkYt"><rect width="685" height="200" rx="30" fill="#FFF"/></mask>
|
||||||
<g mask="url(#PVVTg)">
|
<g mask="url(#uYkYt)">
|
||||||
<rect width="685" height="200" fill="#08C" x="0"/>
|
<rect width="685" height="200" fill="#08C" x="0"/>
|
||||||
<rect width="685" height="200" fill="url(#PUIvu)"/>
|
<rect width="685" height="200" fill="url(#fJMLg)"/>
|
||||||
</g>
|
</g>
|
||||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||||
<text x="65" y="148" textLength="570" fill="#000" opacity="0.25">2025.12.0</text>
|
<text x="65" y="148" textLength="570" fill="#000" opacity="0.25">2025.12.0</text>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 815 B After Width: | Height: | Size: 815 B |
Reference in New Issue
Block a user