-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·44 lines (39 loc) · 1.17 KB
/
run.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
#!/bin/bash
set -eu
NAME=f1tenth_docking_ros
IMAGE=f1tenth_docking_ros
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
if ! [ -d "src" ]; then
echo "Error: directory `src` not found. Please run this script from the root of the f1tenth_docking repository."
exit 1
fi
if ! [ -f "${XAUTH}" ]; then
touch "${XAUTH}"
xauth nlist "${DISPLAY}" | sed -e 's/^..../ffff/' | xauth -f "${XAUTH}" nmerge -
chmod 644 "${XAUTH}"
fi
if [ "$(docker ps -aq -f status=exited -f name="${NAME}")" ]; then
# Start the existing container and attach to it
docker start "${NAME}"
exec docker exec -it "${NAME}" bash
elif [ "$(docker ps -aq -f status=running -f name="${NAME}")" ]; then
# Attach to the running container
exec docker exec -it "${NAME}" bash
else
# Create a new container and attach to it
exec docker run \
-it \
--env=DISPLAY="${DISPLAY}" \
--env=QT_X11_NO_MITSHM=1 \
--env=XDG_RUNTIME_DIR=/tmp \
--env=XAUTHORITY="${XAUTH}" \
--volume="${XAUTH}":"${XAUTH}" \
--volume="${XSOCK}":"${XSOCK}" \
--volume "${PWD}"/src:/root/ws/src \
--volume "${PWD}"/launch:/root/ws/launch \
--network=host \
--name="${NAME}" \
"${IMAGE}" \
bash
fi