From 65e0346ce27e42b74d439423c050f5d086fd6cde Mon Sep 17 00:00:00 2001 From: vahid-dan Date: Wed, 30 Aug 2023 20:24:28 -0500 Subject: [PATCH 1/2] Fix LoRa on pendant node and improve configs --- gateways/base/utils.sh | 5 +++-- gateways/config-files/annie/config.yml | 16 +++++++++------- gateways/config-files/bita/config.yml | 14 ++++++++------ gateways/config-files/bjorn/config.yml | 14 ++++++++------ gateways/config-files/carina/config.yml | 13 +++++++------ gateways/config-files/diana/config.yml | 20 +++++++++++--------- gateways/config-files/henrietta/config.yml | 15 ++++++++------- gateways/config-files/norvel/config.yml | 16 +++++++++------- gateways/cron-jobs/non-root | 8 ++++---- gateways/remote-access/lora-radio.sh | 17 +++++++++-------- 10 files changed, 76 insertions(+), 62 deletions(-) diff --git a/gateways/base/utils.sh b/gateways/base/utils.sh index e2be5bd..33bb9b1 100755 --- a/gateways/base/utils.sh +++ b/gateways/base/utils.sh @@ -89,9 +89,10 @@ export lora_radio_mode=$(yq e '.lora_radio.mode' $config_file) export lora_radio_serial_interface=$(yq e '.lora_radio.serial_interface' $config_file) export lora_radio_lora_interface=$(yq e '.lora_radio.lora_interface' $config_file) export lora_radio_evio_interface=$(yq e '.lora_radio.evio_interface' $config_file) -export lora_radio_switch_interface=$(yq e '.lora_radio.switch_interface' $config_file) +export lora_radio_uplink_interface=$(yq e '.lora_radio.uplink_interface' $config_file) export lora_radio_node_ip=$(yq e '.lora_radio.node_ip' $config_file) -export lora_radio_switch_ip=$(yq e '.lora_radio.switch_ip' $config_file) +export lora_radio_node_netmask=$(yq e '.lora_radio.node_netmask' $config_file) +export lora_radio_lora_gateway_ip=$(yq e '.lora_radio.lora_gateway_ip' $config_file) export lora_radio_baud_rate=$(yq e '.lora_radio.baud_rate' $config_file) export lora_radio_mtu=$(yq e '.lora_radio.mtu' $config_file) export lora_radio_rate=$(yq e '.lora_radio.rate' $config_file) diff --git a/gateways/config-files/annie/config.yml b/gateways/config-files/annie/config.yml index 955a624..20c260d 100644 --- a/gateways/config-files/annie/config.yml +++ b/gateways/config-files/annie/config.yml @@ -88,18 +88,20 @@ lora_radio: mode: noevio # "evio", "noevio", "noevio-nat", or "pendant" serial_interface: ttyUSB0 lora_interface: tnc0 - evio_interface: appCIBR6 - switch_interface: enp1s0 - node_ip: 10.10.101.2/24 # ip/netmask - switch_ip: 10.10.101.1/24 # ip/netmask, IP address of the gateway on the other side of the LoRa link + evio_interface: appCIBR6 # For "evio" mode + uplink_interface: enp1s0 # For "noevio-nat" mode, Interface on the other side of the LoRa link with internet access + node_ip: 10.10.101.2 + node_netmask: /24 + lora_gateway_ip: 10.10.101.1 # For "pendant" mode, IP address of the gateway on the other side of the LoRa link baud_rate: 115200 mtu: 400 # bytes rate: 20 # kbit burst: 32 # kbit latency: 400 # ms - ingress_policing_rate: 10 #kbit - ingress_policing_burst: 10 #kbit - + ingress_policing_rate: 10 # kbit, For "evio" mode + ingress_policing_burst: 10 # kbit, For "evio" mode + nebula_overlay_network: is_enabled: true log_file: nebula-overlay-network.log + \ No newline at end of file diff --git a/gateways/config-files/bita/config.yml b/gateways/config-files/bita/config.yml index 0e87254..69c7e8c 100644 --- a/gateways/config-files/bita/config.yml +++ b/gateways/config-files/bita/config.yml @@ -88,18 +88,20 @@ lora_radio: mode: noevio # "evio", "noevio", "noevio-nat", or "pendant" serial_interface: ttyUSB0 lora_interface: tnc0 - evio_interface: appCIBR6 - switch_interface: enp1s0 - node_ip: 10.10.101.2/24 # ip/netmask - switch_ip: 10.10.101.1/24 # ip/netmask, IP address of the gateway on the other side of the LoRa link + evio_interface: appCIBR6 # For "evio" mode + uplink_interface: enp1s0 # For "noevio-nat" mode, Interface on the other side of the LoRa link with internet access + node_ip: 10.10.101.2 + node_netmask: /24 + lora_gateway_ip: 10.10.101.1 # For "pendant" mode, IP address of the gateway on the other side of the LoRa link baud_rate: 115200 mtu: 400 # bytes rate: 20 # kbit burst: 32 # kbit latency: 400 # ms - ingress_policing_rate: 10 #kbit - ingress_policing_burst: 10 #kbit + ingress_policing_rate: 10 # kbit, For "evio" mode + ingress_policing_burst: 10 # kbit, For "evio" mode nebula_overlay_network: is_enabled: true log_file: nebula-overlay-network.log + \ No newline at end of file diff --git a/gateways/config-files/bjorn/config.yml b/gateways/config-files/bjorn/config.yml index 56ae1d6..45eccf7 100644 --- a/gateways/config-files/bjorn/config.yml +++ b/gateways/config-files/bjorn/config.yml @@ -88,18 +88,20 @@ lora_radio: mode: noevio # "evio", "noevio", "noevio-nat", or "pendant" serial_interface: ttyUSB0 lora_interface: tnc0 - evio_interface: appCIBR6 - switch_interface: enp1s0 - node_ip: 10.10.101.2/24 # ip/netmask - switch_ip: 10.10.101.1/24 # ip/netmask, IP address of the gateway on the other side of the LoRa link + evio_interface: appCIBR6 # For "evio" mode + uplink_interface: enp1s0 # For "noevio-nat" mode, Interface on the other side of the LoRa link with internet access + node_ip: 10.10.101.2 + node_netmask: /24 + lora_gateway_ip: 10.10.101.1 # For "pendant" mode, IP address of the gateway on the other side of the LoRa link baud_rate: 115200 mtu: 400 # bytes rate: 20 # kbit burst: 32 # kbit latency: 400 # ms - ingress_policing_rate: 10 #kbit - ingress_policing_burst: 10 #kbit + ingress_policing_rate: 10 # kbit, For "evio" mode + ingress_policing_burst: 10 # kbit, For "evio" mode nebula_overlay_network: is_enabled: true log_file: nebula-overlay-network.log + \ No newline at end of file diff --git a/gateways/config-files/carina/config.yml b/gateways/config-files/carina/config.yml index 757d5ab..6ffa326 100644 --- a/gateways/config-files/carina/config.yml +++ b/gateways/config-files/carina/config.yml @@ -88,17 +88,18 @@ lora_radio: mode: noevio # "evio", "noevio", "noevio-nat", or "pendant" serial_interface: ttyUSB0 lora_interface: tnc0 - evio_interface: appCIBR6 - switch_interface: enp1s0 - node_ip: 10.10.101.2/24 # ip/netmask - switch_ip: 10.10.101.1/24 # ip/netmask, IP address of the gateway on the other side of the LoRa link + evio_interface: appCIBR6 # For "evio" mode + uplink_interface: enp1s0 # For "noevio-nat" mode, Interface on the other side of the LoRa link with internet access + node_ip: 10.10.101.2 + node_netmask: /24 + lora_gateway_ip: 10.10.101.1 # For "pendant" mode, IP address of the gateway on the other side of the LoRa link baud_rate: 115200 mtu: 400 # bytes rate: 20 # kbit burst: 32 # kbit latency: 400 # ms - ingress_policing_rate: 10 #kbit - ingress_policing_burst: 10 #kbit + ingress_policing_rate: 10 # kbit, For "evio" mode + ingress_policing_burst: 10 # kbit, For "evio" mode nebula_overlay_network: is_enabled: true diff --git a/gateways/config-files/diana/config.yml b/gateways/config-files/diana/config.yml index 0901366..c661473 100644 --- a/gateways/config-files/diana/config.yml +++ b/gateways/config-files/diana/config.yml @@ -43,10 +43,10 @@ git_garbage_collector: - /data/diana-logs health_checks_io: - is_enabled: true + is_enabled: false log_file: health-checks-io.log ping_url: https://hc-ping.com/8c074ee7-de97-4c50-9dfc-987386c0d886 - max_time: 60 + max_time: 300 retry: 5 reverse_ssh: @@ -88,18 +88,20 @@ lora_radio: mode: pendant # "evio", "noevio", "noevio-nat", or "pendant" serial_interface: ttyUSB0 lora_interface: tnc0 - evio_interface: appCIBR6 - switch_interface: enp1s0 - node_ip: 10.10.101.2/24 # ip/netmask - switch_ip: 10.10.101.1/24 # ip/netmask, IP address of the gateway on the other side of the LoRa link + evio_interface: appCIBR6 # For "evio" mode + uplink_interface: enp1s0 # For "noevio-nat" mode, Interface on the other side of the LoRa link with internet access + node_ip: 10.10.101.2 + node_netmask: /24 + lora_gateway_ip: 10.10.101.1 # For "pendant" mode, IP address of the gateway on the other side of the LoRa link baud_rate: 115200 mtu: 400 # bytes rate: 20 # kbit burst: 32 # kbit latency: 400 # ms - ingress_policing_rate: 10 #kbit - ingress_policing_burst: 10 #kbit - + ingress_policing_rate: 10 # kbit, For "evio" mode + ingress_policing_burst: 10 # kbit, For "evio" mode + nebula_overlay_network: is_enabled: true log_file: nebula-overlay-network.log + \ No newline at end of file diff --git a/gateways/config-files/henrietta/config.yml b/gateways/config-files/henrietta/config.yml index a334d56..d253c25 100644 --- a/gateways/config-files/henrietta/config.yml +++ b/gateways/config-files/henrietta/config.yml @@ -88,18 +88,19 @@ lora_radio: mode: noevio # "evio", "noevio", "noevio-nat", or "pendant" serial_interface: ttyUSB0 lora_interface: tnc0 - evio_interface: appCIBR6 - switch_interface: enp1s0 - node_ip: 10.10.101.3/24 # ip/netmask - switch_ip: 10.10.101.1/24 # ip/netmask, IP address of the gateway on the other side of the LoRa link + evio_interface: appCIBR6 # For "evio" mode + uplink_interface: enp1s0 # For "noevio-nat" mode, Interface on the other side of the LoRa link with internet access + node_ip: 10.10.101.3 + node_netmask: /24 + lora_gateway_ip: 10.10.101.1 # For "pendant" mode, IP address of the gateway on the other side of the LoRa link baud_rate: 115200 mtu: 400 # bytes rate: 20 # kbit burst: 32 # kbit latency: 400 # ms - ingress_policing_rate: 10 #kbit - ingress_policing_burst: 10 #kbit - + ingress_policing_rate: 10 # kbit, For "evio" mode + ingress_policing_burst: 10 # kbit, For "evio" mode + nebula_overlay_network: is_enabled: true log_file: nebula-overlay-network.log diff --git a/gateways/config-files/norvel/config.yml b/gateways/config-files/norvel/config.yml index d88c1a3..88f5870 100644 --- a/gateways/config-files/norvel/config.yml +++ b/gateways/config-files/norvel/config.yml @@ -86,18 +86,20 @@ lora_radio: mode: noevio-nat # "evio", "noevio", "noevio-nat", or "pendant" serial_interface: ttyUSB0 lora_interface: tnc0 - evio_interface: appCIBR6 - switch_interface: enx0015ff030033 - node_ip: 10.10.101.1/24 # ip/netmask - switch_ip: 10.10.101.1/24 # ip/netmask, IP address of the gateway on the other side of the LoRa link + evio_interface: appCIBR6 # For "evio" mode + uplink_interface: enx0015ff030033 # For "noevio-nat" mode, Interface on the other side of the LoRa link with internet access + node_ip: 10.10.101.1 + node_netmask: /24 + lora_gateway_ip: 10.10.101.1 # For "pendant" mode, IP address of the gateway on the other side of the LoRa link baud_rate: 115200 mtu: 400 # bytes rate: 20 # kbit burst: 32 # kbit latency: 400 # ms - ingress_policing_rate: 10 #kbit - ingress_policing_burst: 10 #kbit - + ingress_policing_rate: 10 # kbit, For "evio" mode + ingress_policing_burst: 10 # kbit, For "evio" mode + nebula_overlay_network: is_enabled: true log_file: nebula-overlay-network.log + \ No newline at end of file diff --git a/gateways/cron-jobs/non-root b/gateways/cron-jobs/non-root index 408d5ea..75150ea 100644 --- a/gateways/cron-jobs/non-root +++ b/gateways/cron-jobs/non-root @@ -5,10 +5,10 @@ @reboot sleep 90 && /home/ubuntu/miscellaneous/gateways/remote-access/reverse-ssh.sh # Notifies the system is booted up -@reboot sleep 60 && /home/ubuntu/miscellaneous/gateways/system-monitors/startup-notifier.sh +@reboot sleep 90 && /home/ubuntu/miscellaneous/gateways/system-monitors/startup-notifier.sh # Captures and logs the status of the system -@reboot sleep 60 && /home/ubuntu/miscellaneous/gateways/system-monitors/status-monitor.sh +@reboot sleep 90 && /home/ubuntu/miscellaneous/gateways/system-monitors/status-monitor.sh 25 00,08,14,20 * * * /home/ubuntu/miscellaneous/gateways/system-monitors/status-monitor.sh # Pushes the new additions to the remote repo and runs Git garbage collection afterwards @@ -25,9 +25,9 @@ @reboot /home/ubuntu/miscellaneous/gateways/system-monitors/network-interface-monitor.sh # Runs Nebula Overlay Network -@reboot sleep 90 && /home/ubuntu/miscellaneous/gateways/remote-access/nebula-overlay-network.sh +@reboot sleep 60 && /home/ubuntu/miscellaneous/gateways/remote-access/nebula-overlay-network.sh 00 * * * * /home/ubuntu/miscellaneous/gateways/remote-access/nebula-overlay-network.sh # Runs LoRa Radio -@reboot sleep 90 && /home/ubuntu/miscellaneous/gateways/remote-access/lora-radio.sh +@reboot sleep 60 && /home/ubuntu/miscellaneous/gateways/remote-access/lora-radio.sh 00 * * * * /home/ubuntu/miscellaneous/gateways/remote-access/lora-radio.sh diff --git a/gateways/remote-access/lora-radio.sh b/gateways/remote-access/lora-radio.sh index a3fc4b7..e0ac7b8 100755 --- a/gateways/remote-access/lora-radio.sh +++ b/gateways/remote-access/lora-radio.sh @@ -36,15 +36,16 @@ echo "########## START ##########" # Bring lora interface down and up sudo /usr/bin/killall tncattach || true -sleep 5 +sleep 1 -echo "LoRa in $lora_radio_mode mode" case $lora_radio_mode in "pendant") - sudo /usr/local/bin/tncattach /dev/$lora_radio_serial_interface $lora_radio_baud_rate -d -e -n -m $lora_radio_mtu -i $lora_radio_node_ip + sudo /usr/local/bin/tncattach /dev/$lora_radio_serial_interface $lora_radio_baud_rate -d -e -n -m $lora_radio_mtu -i $lora_radio_node_ip$lora_radio_node_netmask sudo /usr/sbin/tc qdisc add dev $lora_radio_lora_interface root tbf rate "$lora_radio_rate"kbit burst "$lora_radio_burst"kbit latency "$lora_radio_latency"ms - sudo /usr/sbin/ip route delete default - sudo /usr/sbin/ip route add default via $lora_radio_switch_ip + if ip route | grep -q default; then + sudo /usr/sbin/ip route delete default + fi + sudo /usr/sbin/ip route add default via $lora_radio_lora_gateway_ip ;; "noevio") @@ -56,9 +57,9 @@ case $lora_radio_mode in sudo /usr/local/bin/tncattach /dev/$lora_radio_serial_interface $lora_radio_baud_rate -d -e -n -m $lora_radio_mtu -i $lora_radio_node_ip sudo /usr/sbin/tc qdisc add dev $lora_radio_lora_interface root tbf rate "$lora_radio_rate"kbit burst "$lora_radio_burst"kbit latency "$lora_radio_latency"ms echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null - sudo /sbin/iptables -t nat -A POSTROUTING -o $lora_radio_switch_interface -j MASQUERADE - sudo /sbin/iptables -A FORWARD -i $lora_radio_switch_interface -o $lora_radio_lora_interface -m state --state RELATED,ESTABLISHED -j ACCEPT - sudo /sbin/iptables -A FORWARD -i $lora_radio_lora_interface -o $lora_radio_switch_interface -j ACCEPT + sudo /sbin/iptables -t nat -A POSTROUTING -o $lora_radio_uplink_interface -j MASQUERADE + sudo /sbin/iptables -A FORWARD -i $lora_radio_uplink_interface -o $lora_radio_lora_interface -m state --state RELATED,ESTABLISHED -j ACCEPT + sudo /sbin/iptables -A FORWARD -i $lora_radio_lora_interface -o $lora_radio_uplink_interface -j ACCEPT ;; "evio") From 20f8f1bf99356727759887e692585a57f5074bda Mon Sep 17 00:00:00 2001 From: vahid-dan Date: Wed, 30 Aug 2023 20:25:03 -0500 Subject: [PATCH 2/2] Update git push --- gateways/git-maintenance/git-push.sh | 2 +- gateways/system-monitors/startup-notifier.sh | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gateways/git-maintenance/git-push.sh b/gateways/git-maintenance/git-push.sh index f0ec10d..ae40e61 100755 --- a/gateways/git-maintenance/git-push.sh +++ b/gateways/git-maintenance/git-push.sh @@ -26,7 +26,7 @@ echo "########## START ##########" readarray -t dir_array <<< "$git_push_directories" for dir in "${dir_array[@]}"; do - timestamp=$(date +"%D %T %Z %z") + timestamp=$(date +"%a %Y-%m-%d %T %Z") echo "Processing: $dir" cd "$dir" || continue git add . diff --git a/gateways/system-monitors/startup-notifier.sh b/gateways/system-monitors/startup-notifier.sh index e4bc9fb..f86886c 100755 --- a/gateways/system-monitors/startup-notifier.sh +++ b/gateways/system-monitors/startup-notifier.sh @@ -24,10 +24,13 @@ echo "########## START ##########" cd $general_apps_dir/$startup_notifier_local_repo_dir/$general_gateway_name date > $general_gateway_name +timestamp=$(date +"%a %Y-%m-%d %T %Z") git add $general_gateway_name -git commit -m "$(date +"%D %T %Z %z")" +git commit -m "$timestamp" git pull --rebase -git push +for commit in $(git log --reverse --format="%H" --branches --not --remotes); do + git push --force origin $commit:refs/heads/$(git rev-parse --abbrev-ref HEAD) || continue +done ########## FOOTER ##########