From 8eed831ce1c8e2d02b3beeeb22ec8a67d55cf502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ellensohn?= Date: Tue, 14 Nov 2023 14:55:16 +0100 Subject: [PATCH] save --- customize/cyclonedds_zerotier.xml | 26 +++++++++++++++++++ customize/entrypoint.sh | 42 ++++++++++++++++++++++++++++--- docker-compose.yaml | 2 ++ 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 customize/cyclonedds_zerotier.xml diff --git a/customize/cyclonedds_zerotier.xml b/customize/cyclonedds_zerotier.xml new file mode 100644 index 0000000..a4de950 --- /dev/null +++ b/customize/cyclonedds_zerotier.xml @@ -0,0 +1,26 @@ + + + + + zt3jn7jpga + true + 1194B + udp6 + + + + + auto + 40 + + + + 500kB + + + + severe + stdout + + + \ No newline at end of file diff --git a/customize/entrypoint.sh b/customize/entrypoint.sh index fc931be..6f5eb31 100755 --- a/customize/entrypoint.sh +++ b/customize/entrypoint.sh @@ -53,12 +53,46 @@ fi # /zerotier-one/zerotier-cli join 8056c2e21c000001 # echo "Joined zerotier network" # fi -# set standard gateway to zerotier interface -ip route del default -ip route add default via $(ip addr show zt0 | grep -Po 'inet \K[\d.]+') -echo "Set zerotier interface as standard gateway" +# # set standard gateway to zerotier interface +# ip route del default +# ip route add default via $(ip addr show zt* | grep -Po 'inet \K[\d.]+') +# echo "Set zerotier interface as standard gateway" # this should now route the ros2 traffic through zerotier? +# # Find the ZeroTier interface name dynamically +# zerotier_interface=$(ip addr show | awk '/^.*: zt/{print $2}' | cut -d ':' -f 1) + +# if [ -z "$zerotier_interface" ]; then +# echo "ZeroTier interface not found." +# exit 1 +# fi + +# # Set the standard gateway to the ZeroTier interface +# ip route del default +# ip route add default via $(ip addr show "$zerotier_interface" | grep -Po 'inet \K[\d.]+') + +# echo "Set ZeroTier interface '$zerotier_interface' as the standard gateway." + +# Changing apporach to just configure the cyconedds to use the zerotier interface + +# For now add respective ip apps to do the stuff below: +apt update && apt install -y iproute2 + +# Find the ZeroTier interface name dynamically +zerotier_interface=$(ip addr show | awk '/^.*: zt/{print $2}' | cut -d ':' -f 1) + +if [ -z "$zerotier_interface" ]; then + echo "ZeroTier interface not found." + exit 1 +fi + +echo "Using ZeroTier interface: $zerotier_interface" + +# Set the path to your CycloneDDS configuration file +config_file="/cyclonedds.xml" + +# Replace the content between tags +sed -i "s|.*|$zerotier_interface|g" "$config_file" # Execute the command passed into this entrypoint exec "$@" \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 6fb7826..2dcc1d5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -54,11 +54,13 @@ services: # set correct ros2 parameters: domain id and rmw implementation - ROS_DOMAIN_ID=5 - RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + - CYCLONEDDS_URI=file:///cyclonedds.xml volumes: # Allows graphical programs in the container. - /tmp/.X11-unix:/tmp/.X11-unix:rw - ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority - ./customize/entrypoint.sh:/entrypoint.sh + - ./customize/cyclonedds_zerotier.xml:/cyclonedds.xml # networks: # not using bridging anymore, instead try using all services on macvlan? let's see... shoudl word for now. Bridging does definitely not work because multicast is not supported here. # rmp: