-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
45 lines (36 loc) · 1.48 KB
/
docker-entrypoint.sh
File metadata and controls
45 lines (36 loc) · 1.48 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
#!/bin/bash
# Entrypoint script to build workspace if needed
set -e
cd /workspace
# Check if we need to rebuild (install doesn't exist, is empty, or has wrong paths)
NEED_REBUILD=false
if [ ! -d "install" ] || [ -z "$(ls -A install)" ]; then
NEED_REBUILD=true
elif [ -f "install/setup.bash" ]; then
# Check if setup.bash contains wrong paths (from host build or different ROS distro)
if grep -q "/home/kunj13/slam_frontend_ws" install/setup.bash 2>/dev/null || \
grep -q "/home/.*/slam_frontend_ws" install/setup.bash 2>/dev/null || \
grep -q "/opt/ros/humble" install/setup.bash 2>/dev/null; then
echo "Detected wrong paths in setup.bash (host paths or wrong ROS distro), rebuilding workspace..."
NEED_REBUILD=true
fi
fi
# Check if scripts directory exists in source but not in install
if [ -d "rwa2_starter/slam_frontend/scripts" ] && \
[ ! -f "install/slam_frontend/share/slam_frontend/scripts/play_bag.py" ]; then
echo "Detected new scripts directory, rebuilding workspace..."
NEED_REBUILD=true
fi
if [ "$NEED_REBUILD" = true ]; then
echo "Building workspace..."
source /opt/ros/jazzy/setup.bash
colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja --event-handlers console_cohesion+
echo "Workspace build complete!"
fi
# Source ROS and workspace
source /opt/ros/jazzy/setup.bash
if [ -f /workspace/install/setup.bash ]; then
source /workspace/install/setup.bash
fi
# Execute command
exec "$@"