diff --git a/.env b/.env index c9326dc..8c11247 100644 --- a/.env +++ b/.env @@ -1,9 +1,11 @@ # Configuration for xbnet0 -XBEE0_PORT=/dev/ttyUSB1 -XBEE0_NET_IP=192.168.10.1 -PING0_TARGET=192.168.10.2 +XBEE0_PORT=/dev/ttyUSB0 +XBEE0_BAUDRATE=/dev/ttyUSB0 +XBEE0_NET_SRC_IP=192.168.8.1 +XBEE0_NET_DST_IP=192.168.8.2 # Configuration for xbnet1 -XBEE1_PORT=/dev/ttyUSB2 -XBEE1_NET_IP=192.168.10.2 -PING1_TARGET=192.168.10.1 +XBEE1_PORT=/dev/ttyUSB1 +XBEE1_BAUDRATE=/dev/ttyUSB1 +XBEE1_NET_SRC_IP=192.168.8.2 +XBEE1_NET_DST_IP=192.168.8.1 diff --git a/Dockerfile b/Dockerfile index 4a5c3a1..c20f392 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,16 +13,14 @@ RUN git clone https://github.com/jgoerzen/xbnet.git /usr/src/xbnet # Build xbnet WORKDIR /usr/src/xbnet -RUN cargo build --release +RUN cargo build && cargo build --release # Copy the built binary to /usr/local/bin RUN cp target/release/xbnet /usr/local/bin/xbnet -# Create the entrypoint script -RUN echo '#!/bin/bash\n\ -set -e\n\ -exec "$@"' > /entrypoint.sh \ - && chmod +x /entrypoint.sh +# Create and copy the entrypoint script to root location "/" +COPY ./entrypoint.sh / +RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] CMD ["bash"] diff --git a/docker-compose-run-multiple.yml b/docker-compose-run-multiple.yml index c1e7f6f..d3959c8 100644 --- a/docker-compose-run-multiple.yml +++ b/docker-compose-run-multiple.yml @@ -12,7 +12,7 @@ services: command: > bash -c " set -x; - xbnet ${XBEE0_PORT} tun; + xbnet -d --serial-speed ${XBEE0_BAUDRATE} ${XBEE0_PORT} tun; ip addr add ${XBEE0_NET_IP}/24 dev xbnet0; ip link set dev xbnet0 up; ping -c 4 ${PING0_TARGET}; @@ -30,7 +30,7 @@ services: command: > bash -c " set -x; - xbnet ${XBEE1_PORT} tun; + xbnet -d --serial-speed ${XBEE1_BAUDRATE} ${XBEE0_PORT} tun; ip addr add ${XBEE1_NET_IP}/24 dev xbnet1; ip link set dev xbnet1 up; ping -c 4 ${PING1_TARGET}; diff --git a/docker-compose.yml b/docker-compose.yml index 573f3db..da625cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,9 +11,9 @@ services: - "${XBEE0_PORT}:${XBEE0_PORT}" command: > bash -c " - xbnet ${XBEE0_PORT} tun; - ip addr add ${XBEE0_NET_IP}/24 dev xbnet0; + xbnet -d --serial-speed ${XBEE0_BAUDRATE} ${XBEE0_PORT} tun; + ip addr add ${XBEE1_NET_SRC_IP}/24 dev xbnet0; ip link set dev xbnet0 up; - ping -c 4 ${PING0_TARGET}; + ping -c 4 ${XBEE1_NET_DST_IP}; sleep infinity " diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..1a91860 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +set -e +exec "$@" \ No newline at end of file diff --git a/scripts/get_connected_wifi_name.sh b/scripts/get_connected_wifi_info.sh similarity index 100% rename from scripts/get_connected_wifi_name.sh rename to scripts/get_connected_wifi_info.sh diff --git a/scripts/test.sh b/scripts/test.sh index dde4c5b..9fab0cf 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,9 +1,8 @@ #!/bin/bash -# Source and call get_connected_wifi_name call_get_connected_wifi_name() { - # Source the get_connected_wifi_name.sh script - source ./scripts/get_connected_wifi_name.sh + # Source the get_connected_wifi_info.sh script + source ./scripts/get_connected_wifi_info.sh # Call the function to get the Wi-Fi name and capture the returned Wi-Fi name wifi_name=$(get_connected_wifi_name) @@ -16,10 +15,9 @@ call_get_connected_wifi_name() { fi } -# Source and call get_connected_wifi_device call_get_connected_wifi_device() { - # Source the get_connected_wifi_name.sh script - source ./scripts/get_connected_wifi_name.sh + # Source the get_connected_wifi_info.sh script + source ./scripts/get_connected_wifi_info.sh # Call the function to get the Wi-Fi device and capture the returned Wi-Fi device wifi_device=$(get_connected_wifi_device) diff --git a/test/test-run-cleanup.sh b/tests/test-run-cleanup.sh similarity index 100% rename from test/test-run-cleanup.sh rename to tests/test-run-cleanup.sh diff --git a/test/test-run.sh b/tests/test-run.sh similarity index 100% rename from test/test-run.sh rename to tests/test-run.sh