From 4b19fc06ead2e7ea4d324ec97bc2f5b582191cf8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 Jan 2018 11:36:50 +0000 Subject: [PATCH] Stopping mesh protocol before starting another --- src/freedombone-mesh-batman | 8 ++++++++ src/freedombone-mesh-bmx6 | 9 ++++++++- src/freedombone-utils-mesh | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/freedombone-mesh-batman b/src/freedombone-mesh-batman index 4507af49..8ea92a71 100755 --- a/src/freedombone-mesh-batman +++ b/src/freedombone-mesh-batman @@ -97,6 +97,10 @@ function stop { disable_mesh_firewall systemctl restart network-manager + + if [ -f $MESH_CURRENT_PROTOCOL ]; then + rm $MESH_CURRENT_PROTOCOL + fi } function verify { @@ -152,6 +156,8 @@ function start { fi echo "info: enabling batman-adv mesh network $WIFI_SSID on $IFACE" + mesh_protocol_stop + systemctl stop network-manager sleep 5 @@ -225,6 +231,8 @@ function start { systemctl restart nginx verify + + echo "batman-adv" > $MESH_CURRENT_PROTOCOL } function monitor { diff --git a/src/freedombone-mesh-bmx6 b/src/freedombone-mesh-bmx6 index e8366c07..97244df3 100755 --- a/src/freedombone-mesh-bmx6 +++ b/src/freedombone-mesh-bmx6 @@ -87,6 +87,10 @@ function stop { disable_mesh_firewall systemctl restart network-manager + + if [ -f $MESH_CURRENT_PROTOCOL ]; then + rm $MESH_CURRENT_PROTOCOL + fi } function verify { @@ -133,7 +137,8 @@ function start { fi echo "info: enabling BMX6 mesh network $WIFI_SSID on $IFACE" - batman stop + mesh_protocol_stop + systemctl stop network-manager sleep 5 @@ -207,6 +212,8 @@ function start { systemctl restart nginx verify + + echo "bmx6" > $MESH_CURRENT_PROTOCOL } function monitor { diff --git a/src/freedombone-utils-mesh b/src/freedombone-utils-mesh index 9fb168cd..0a476bfd 100755 --- a/src/freedombone-utils-mesh +++ b/src/freedombone-utils-mesh @@ -28,6 +28,25 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +# File which contains the current protocol in use +MESH_CURRENT_PROTOCOL=~/.mesh_protocol + +function mesh_protocol_stop { + if [ ! -f $MESH_CURRENT_PROTOCOL ]; then + return + fi + + if grep -q "bmx6" $MESH_CURRENT_PROTOCOL; then + bmx stop + fi + + if grep -q "batman-adv" $MESH_CURRENT_PROTOCOL; then + batman stop + fi + + rm $MESH_CURRENT_PROTOCOL +} + function mesh_protocol_init { if [[ $1 == "start" ]]; then # install avahi