-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathjoin.sh
More file actions
executable file
·51 lines (44 loc) · 1.03 KB
/
join.sh
File metadata and controls
executable file
·51 lines (44 loc) · 1.03 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
#!/usr/bin/env bash
set -e
# Configuration
CONTAINER_NAME="ros2-testing-workshop-roscon-es-25-container"
# Helper function
function print_usage() {
echo "Usage: $0 [OPTIONS] [COMMAND]"
echo "Joins a running container for the ROS 2 workshop."
echo
echo "Options:"
echo " -c, --container <name> Container name to join (default: ${CONTAINER_NAME})"
echo " -h, --help Show this help message"
echo
echo "Any additional arguments are passed to the container's entrypoint."
}
# Parse args
ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-c|--container)
CONTAINER_NAME="$2"
shift; shift
;;
-h|--help)
print_usage
exit 0
;;
*)
# Forward unknown args to docker exec
ARGS+=("$1")
shift
;;
esac
done
# Default command if none provided
if [[ ${#ARGS[@]} -eq 0 ]]; then
ARGS=("bash")
fi
# Allow GUI applications
xhost +
# Join a running container
docker exec -it "$CONTAINER_NAME" "${ARGS[@]}"
# Disallow GUI applications after container exits
xhost -