ok... ok... I'll add it to git...
This commit is contained in:
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
# Update Docker Stacks Script
|
||||
# Pull latest images and recreate containers
|
||||
|
||||
set -e
|
||||
|
||||
STACKS_DIR="/home/jpmschweitzer/Projects/tower-of-joy/stacks"
|
||||
|
||||
# Show usage
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
echo "Usage: $0 [stack-name]"
|
||||
echo ""
|
||||
echo "Update a specific stack or all stacks"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 portainer # Update only Portainer"
|
||||
echo " $0 ollama # Update only Ollama"
|
||||
echo " $0 # Update all stacks (interactive)"
|
||||
echo ""
|
||||
echo "Available stacks:"
|
||||
ls -1 "$STACKS_DIR"/*.yml 2>/dev/null | xargs -n 1 basename | sed 's/.yml$//' | sed 's/^/ - /'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Function to update a stack
|
||||
update_stack() {
|
||||
local stack_file=$1
|
||||
local stack_name=$(basename "$stack_file" .yml)
|
||||
|
||||
echo ""
|
||||
echo "=== Updating $stack_name ==="
|
||||
|
||||
# Pull latest images
|
||||
echo "[1/3] Pulling latest images..."
|
||||
docker compose -f "$stack_file" pull
|
||||
|
||||
# Recreate containers
|
||||
echo "[2/3] Recreating containers..."
|
||||
docker compose -f "$stack_file" up -d
|
||||
|
||||
# Verify containers running
|
||||
echo "[3/3] Verifying containers..."
|
||||
sleep 2
|
||||
if docker compose -f "$stack_file" ps | grep -q "Up"; then
|
||||
echo "✅ $stack_name updated successfully"
|
||||
else
|
||||
echo "⚠️ $stack_name may have issues, check logs"
|
||||
fi
|
||||
}
|
||||
|
||||
# If specific stack provided
|
||||
if [ -n "$1" ]; then
|
||||
STACK_FILE="$STACKS_DIR/$1.yml"
|
||||
if [ -f "$STACK_FILE" ]; then
|
||||
update_stack "$STACK_FILE"
|
||||
else
|
||||
echo "❌ Stack not found: $1"
|
||||
echo "Available stacks:"
|
||||
ls -1 "$STACKS_DIR"/*.yml 2>/dev/null | xargs -n 1 basename | sed 's/.yml$//' | sed 's/^/ - /'
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Interactive mode - update all stacks
|
||||
echo "=== Update All Stacks ==="
|
||||
echo ""
|
||||
echo "This will update all deployed stacks to the latest images."
|
||||
read -p "Continue? (y/N) " -n 1 -r
|
||||
echo
|
||||
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
for stack_file in "$STACKS_DIR"/*.yml; do
|
||||
if [ -f "$stack_file" ]; then
|
||||
update_stack "$stack_file"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
echo "=== All Stacks Updated ==="
|
||||
else
|
||||
echo "Update cancelled"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user