testing gateway

This commit is contained in:
Emran Billah 2024-08-28 13:43:03 -03:00
parent 449a4fb4a2
commit fab1d2a805
3 changed files with 15 additions and 10 deletions

View File

@ -36,8 +36,8 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY ./scripts/health_check.sh /health_check.sh COPY ./scripts/health_check.sh /health_check.sh
RUN chmod +x /health_check.sh RUN chmod +x /health_check.sh
# Start supervisord as the main command # # Start supervisord as the main command
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] # CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
# Add healthcheck # Add healthcheck
HEALTHCHECK CMD /health_check.sh || exit 1 HEALTHCHECK CMD /health_check.sh || exit 1

View File

@ -68,6 +68,8 @@ services:
container_name: xbnet_node container_name: xbnet_node
privileged: true privileged: true
env_file: .env env_file: .env
command: /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
# command: tail -f /dev/null
# networks: # networks:
# xbee_net: # xbee_net:
# ipv4_address: ${XBEE_NET_SRC_IP} # Ensure this IP belongs to the xbee_net subnet # ipv4_address: ${XBEE_NET_SRC_IP} # Ensure this IP belongs to the xbee_net subnet

View File

@ -114,9 +114,9 @@
# echo "Wi-Fi interface found: $HOST_WIFI_IFACE. Bridging with $XBEE_NET_IFACE_NAME..." # echo "Wi-Fi interface found: $HOST_WIFI_IFACE. Bridging with $XBEE_NET_IFACE_NAME..."
# brctl addif br0 $HOST_WIFI_IFACE # brctl addif br0 $HOST_WIFI_IFACE
# # sudo iptables -t nat -A POSTROUTING -s ${DEFAULT_SUBNET}.0/24 -o $HOST_WIFI_IFACE -j MASQUERADE # # 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 # # iptables -A FORWARD -i $HOST_WIFI_IFACE -o docker0 -j ACCEPT
# # sudo iptables -A FORWARD -i docker0 -o $HOST_WIFI_IFACE -j ACCEPT # # iptables -A FORWARD -i docker0 -o $HOST_WIFI_IFACE -j ACCEPT
# echo "Bridge configured. Monitoring for changes..." # echo "Bridge configured. Monitoring for changes..."
# break # break
@ -202,9 +202,7 @@ loop() {
# Check if the network interface is up # Check if the network interface is up
check_network_state check_network_state
if [ $? -eq 0 ]; then if [ $? -ne 0 ]; then
echo "Network interface $XBEE_NET_IFACE_NAME is already up."
else
echo "Network interface $XBEE_NET_IFACE_NAME not found. Creating TAP interface..." echo "Network interface $XBEE_NET_IFACE_NAME not found. Creating TAP interface..."
create_tap_interface create_tap_interface
fi fi
@ -236,6 +234,7 @@ check_network_state() {
# Function to create a TAP network interface # Function to create a TAP network interface
create_tap_interface() { create_tap_interface() {
# Start xbnet and run it in the background # 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} & xbnet -d --serial-speed ${XBEE_BAUDRATE} ${XBEE_PORT} tap --iface-name ${XBEE_NET_IFACE_NAME} &
# Wait until the interface is created # Wait until the interface is created
@ -243,11 +242,15 @@ create_tap_interface() {
sleep 1 sleep 1
done done
sudo ip addr add $XBEE_NET_SRC_IP/24 dev $XBEE_NET_IFACE_NAME echo "Triggering ip addr add cmd"
sudo ip link set $XBEE_NET_IFACE_NAME up 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 "Tap interface created."
echo "Name: ${XBEE_NET_IFACE_NAME}" echo "Name: ${XBEE_NET_IFACE_NAME}"
echo "Gateway: ${DEFAULT_GATEWAY}"
echo "IP: ${XBEE_NET_SRC_IP}" echo "IP: ${XBEE_NET_SRC_IP}"
echo "Device port: ${XBEE_PORT}" echo "Device port: ${XBEE_PORT}"
echo "Device baudrate: ${XBEE_BAUDRATE}" echo "Device baudrate: ${XBEE_BAUDRATE}"