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
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

View File

@ -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

View File

@ -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}"