forked from red-hat-data-services/agentic-starter-kits
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup-local.sh
More file actions
executable file
·31 lines (28 loc) · 1.12 KB
/
cleanup-local.sh
File metadata and controls
executable file
·31 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
# Cleanup script — keeps going on errors to clean up as much as possible
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOCAL_DIR="$SCRIPT_DIR/local"
cd "$LOCAL_DIR" || { echo "ERROR: Directory $LOCAL_DIR not found."; exit 1; }
if [ "${1:-}" = "--force" ]; then
echo "Stopping services and removing all data..."
# Stop containerized services
podman-compose down --remove-orphans -v -t 5 || true
# Force kill and remove any lingering containers from this compose project
for c in $(podman ps -a --filter "label=io.podman.compose.project=local" -q 2>/dev/null); do
podman rm -f "$c" || true
done
# Remove project volumes
for v in $(podman volume ls --filter "label=io.podman.compose.project=local" -q 2>/dev/null); do
podman volume rm -f "$v" || true
done
# Remove project network
podman network rm local_default || true
# Clean up config
rm -f "$LOCAL_DIR/.env"
echo "Done. All services stopped and data removed."
else
echo "Stopping services (data preserved)..."
podman-compose down --remove-orphans || true
echo "Done. Run 'make run' to start again."
fi