-
Notifications
You must be signed in to change notification settings - Fork 69
/
run_docker.sh
48 lines (41 loc) · 1007 Bytes
/
run_docker.sh
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
#!/bin/bash
usage(){
echo "Usage: $0 [-r <humble|iron|rolling>]"
exit 1
}
ROS_DISTRO=${ROS_DISTRO:-"iron"} # [humble, iron, rolling]
while getopts "r:" opt; do
case $opt in
r)
if [ $OPTARG != "humble" ] && [ $OPTARG != "iron" ] && [ $OPTARG != "rolling" ]; then
echo "Invalid ROS distro: $OPTARG" >&2
usage
fi
ROS_DISTRO=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
;;
esac
done
XSOCK=/tmp/.X11-unix
XAUTH=$HOME/.Xauthority
docker pull georgno/sjtu_drone:ros2-${ROS_DISTRO}
if [ $? -ne 0 ]; then
exit 1
fi
xhost +local:docker
docker run \
-it --rm \
$VOLUMES \
-v ${XSOCK}:${XSOCK} \
-v ${XAUTH}:${XAUTH} \
-e DISPLAY=${DISPLAY} \
-e XAUTHORITY=${XAUTH} \
--env=QT_X11_NO_MITSHM=1 \
--privileged \
--net=host \
--name="sjtu_drone" \
georgno/sjtu_drone:ros2-${ROS_DISTRO}
xhost -local:docker