diff --git a/Dockerfile b/Dockerfile index c627bd0..6e62ae4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,8 +36,8 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY ./scripts/health_check.sh /health_check.sh RUN chmod +x /health_check.sh -# Start supervisord as the main command -CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] +# # Start supervisord as the main command +# CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] # Add healthcheck HEALTHCHECK CMD /health_check.sh || exit 1 diff --git a/docker-compose-run-single.yml b/docker-compose-run-single.yml index 2a71af1..e72b13a 100644 --- a/docker-compose-run-single.yml +++ b/docker-compose-run-single.yml @@ -68,6 +68,8 @@ services: container_name: xbnet_node privileged: true env_file: .env + command: /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf + # command: tail -f /dev/null # networks: # xbee_net: # ipv4_address: ${XBEE_NET_SRC_IP} # Ensure this IP belongs to the xbee_net subnet diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 6f31d45..1e747a4 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -114,9 +114,9 @@ # echo "Wi-Fi interface found: $HOST_WIFI_IFACE. Bridging with $XBEE_NET_IFACE_NAME..." # brctl addif br0 $HOST_WIFI_IFACE -# # sudo iptables -t nat -A POSTROUTING -s ${DEFAULT_SUBNET}.0/24 -o $HOST_WIFI_IFACE -j MASQUERADE -# # sudo iptables -A FORWARD -i $HOST_WIFI_IFACE -o docker0 -j ACCEPT -# # sudo iptables -A FORWARD -i docker0 -o $HOST_WIFI_IFACE -j ACCEPT +# # iptables -t nat -A POSTROUTING -s ${DEFAULT_SUBNET}.0/24 -o $HOST_WIFI_IFACE -j MASQUERADE +# # iptables -A FORWARD -i $HOST_WIFI_IFACE -o docker0 -j ACCEPT +# # iptables -A FORWARD -i docker0 -o $HOST_WIFI_IFACE -j ACCEPT # echo "Bridge configured. Monitoring for changes..." # break @@ -202,9 +202,7 @@ loop() { # Check if the network interface is up check_network_state - if [ $? -eq 0 ]; then - echo "Network interface $XBEE_NET_IFACE_NAME is already up." - else + if [ $? -ne 0 ]; then echo "Network interface $XBEE_NET_IFACE_NAME not found. Creating TAP interface..." create_tap_interface fi @@ -236,6 +234,7 @@ check_network_state() { # Function to create a TAP network interface create_tap_interface() { # Start xbnet and run it in the background + echo "Triggering xbnet cmd" xbnet -d --serial-speed ${XBEE_BAUDRATE} ${XBEE_PORT} tap --iface-name ${XBEE_NET_IFACE_NAME} & # Wait until the interface is created @@ -243,11 +242,15 @@ create_tap_interface() { sleep 1 done - sudo ip addr add $XBEE_NET_SRC_IP/24 dev $XBEE_NET_IFACE_NAME - sudo ip link set $XBEE_NET_IFACE_NAME up + echo "Triggering ip addr add cmd" + ip addr add $XBEE_NET_SRC_IP/24 dev $XBEE_NET_IFACE_NAME + + echo "Triggering ip link set cmd" + ip link set $XBEE_NET_IFACE_NAME up echo "Tap interface created." echo "Name: ${XBEE_NET_IFACE_NAME}" + echo "Gateway: ${DEFAULT_GATEWAY}" echo "IP: ${XBEE_NET_SRC_IP}" echo "Device port: ${XBEE_PORT}" echo "Device baudrate: ${XBEE_BAUDRATE}"