-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstop-demo.sh
More file actions
executable file
·74 lines (64 loc) · 1.73 KB
/
Copy pathstop-demo.sh
File metadata and controls
executable file
·74 lines (64 loc) · 1.73 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Stop TurtleBot3 + ros2_medkit Demo
set -eu
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "🛑 Stopping TurtleBot3 + ros2_medkit Demo"
echo "=========================================="
# Check for Docker
if ! command -v docker &> /dev/null; then
echo "Error: Docker is not installed"
exit 1
fi
# Parse arguments
REMOVE_VOLUMES=""
REMOVE_IMAGES=""
usage() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -v, --volumes Remove named volumes"
echo " --images Remove images"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Stop containers"
echo " $0 --volumes # Stop and remove volumes"
echo " $0 --images # Stop and remove images"
}
while [[ $# -gt 0 ]]; do
case "$1" in
-v|--volumes)
echo "Will remove named volumes"
REMOVE_VOLUMES="-v"
;;
--images)
echo "Will remove images"
REMOVE_IMAGES="--rmi all"
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
shift
done
# Stop containers
echo "Stopping containers..."
if docker compose version &> /dev/null; then
# shellcheck disable=SC2086
docker compose --profile cpu --profile nvidia down ${REMOVE_VOLUMES} ${REMOVE_IMAGES}
else
# shellcheck disable=SC2086
docker-compose --profile cpu --profile nvidia down ${REMOVE_VOLUMES} ${REMOVE_IMAGES}
fi
# Cleanup X11
echo "Cleaning up X11 permissions..."
xhost -local:docker 2>/dev/null || true
echo ""
echo "✅ Demo stopped successfully!"