Skip to content

Commit

Permalink
make ros_entrypoint universal
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Dec 29, 2023
1 parent 8e8e3a4 commit 63389a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
5 changes: 5 additions & 0 deletions Dockerfile.hardware
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,8 @@ ENV ROS_NAMESPACE=

HEALTHCHECK --interval=5s --timeout=2s --start-period=10s --retries=6 \
CMD ["/healthcheck.sh"]

RUN new_content1='source "/ros2_ws_healthcheck/install/setup.bash"' && \
new_content2='gosu $USER bash -c "ros2 run healthcheck_pkg healthcheck_node &"' && \
sed -i "/exec/i $new_content1" /ros_entrypoint.sh && \
sed -i "/exec/i $new_content2" /ros_entrypoint.sh
12 changes: 1 addition & 11 deletions ros_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,14 @@ if [[ "$HUSARNET_DDS_DEBUG" == "TRUE" ]]; then
echo "$output"
fi

# Check if XRCE_DOMAIN_ID_OVERRIDE is unset or empty
if [ -z "$XRCE_DOMAIN_ID_OVERRIDE" ]; then
# If ROS_DOMAIN_ID is set and not empty, set XRCE_DOMAIN_ID_OVERRIDE to its value
if [ -n "$ROS_DOMAIN_ID" ]; then
export XRCE_DOMAIN_ID_OVERRIDE="$ROS_DOMAIN_ID"
fi
fi

# setup ros environment
source "/opt/ros/$ROS_DISTRO/setup.bash"
source "/ros2_ws/install/setup.bash"
source "/ros2_ws_healthcheck/install/setup.bash"
test -f "/ros2_ws/install/setup.bash" && source "/ros2_ws/install/setup.bash"

if [ -z "$USER" ]; then
export USER=root
elif ! id "$USER" &>/dev/null; then
useradd -ms /bin/bash "$USER"
fi

gosu $USER bash -c "ros2 run healthcheck_pkg healthcheck_node &"
exec gosu $USER "$@"

0 comments on commit 63389a4

Please sign in to comment.