-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_container.sh
executable file
·60 lines (53 loc) · 1.78 KB
/
create_container.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
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
container_name="sabes_container_noetic" # Change this to your container name
catkin_ws_path="/sabes_ws/darknet_ros_3d_v1/catkin_ws" # Change this to your catkin_ws path
xhost +
#sudo
docker run \
--net=host \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--volume="$HOME/.Xauthority:/root/.Xauthority:rw" \
--volume=/home/cemkgenc/sabes_ws:/sabes_ws \
--volume=/dev:/dev \
--device-cgroup-rule='c 81:* rmw' \
--device-cgroup-rule='c 189:* rmw' \
--env="DISPLAY=$DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--name $container_name \
-it \
-d \
sabes_image_noetic
sleep 2
# ANSI escape codes for colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RESET='\033[0m'
#sudo
docker exec -it $container_name bash -c "
sudo apt update && sudo apt upgrade -y
if [ -f '/opt/ros/noetic/setup.bash' ]; then
source /opt/ros/noetic/setup.bash && \
if [ \$? -eq 0 ]; then
echo -e '${GREEN}ROS distro sourced as${RESET}' \$ROS_DISTRO
else
echo -e '${RED}Failed to source ROS distro${RESET}'
fi
else
echo -e '${YELLOW}/opt/ros/noetic/setup.bash does not exist yet. Skipping sourcing.${RESET}'
fi && \
if [ -f '$catkin_ws_path/devel/setup.bash' ]; then
source $catkin_ws_path/devel/setup.bash && \
if [ \$? -eq 0 ]; then
echo -e '${GREEN}ROS workspace sourced as${RESET}' $catkin_ws_path
else
echo -e '${RED}Failed to source ROS workspace${RESET}' $catkin_ws_path
fi
else
echo -e '${YELLOW}$catkin_ws_path/devel/setup.bash does not exist yet. Skipping sourcing.${RESET}'
fi && \
bash"
exit 0
# To run this script in terminal:
# sudo chmod +x create_container.sh
# ./create_container.sh