Ver código fonte

Stopping mesh protocol before starting another

Bob Mottram 7 anos atrás
pai
commit
4b19fc06ea

+ 8
- 0
src/freedombone-mesh-batman Ver arquivo

@@ -97,6 +97,10 @@ function stop {
97 97
     disable_mesh_firewall
98 98
 
99 99
     systemctl restart network-manager
100
+
101
+    if [ -f $MESH_CURRENT_PROTOCOL ]; then
102
+        rm $MESH_CURRENT_PROTOCOL
103
+    fi
100 104
 }
101 105
 
102 106
 function verify {
@@ -152,6 +156,8 @@ function start {
152 156
     fi
153 157
     echo "info: enabling batman-adv mesh network $WIFI_SSID on $IFACE"
154 158
 
159
+    mesh_protocol_stop
160
+
155 161
     systemctl stop network-manager
156 162
     sleep 5
157 163
 
@@ -225,6 +231,8 @@ function start {
225 231
     systemctl restart nginx
226 232
 
227 233
     verify
234
+
235
+    echo "batman-adv" > $MESH_CURRENT_PROTOCOL
228 236
 }
229 237
 
230 238
 function monitor {

+ 8
- 1
src/freedombone-mesh-bmx6 Ver arquivo

@@ -87,6 +87,10 @@ function stop {
87 87
     disable_mesh_firewall
88 88
 
89 89
     systemctl restart network-manager
90
+
91
+    if [ -f $MESH_CURRENT_PROTOCOL ]; then
92
+        rm $MESH_CURRENT_PROTOCOL
93
+    fi
90 94
 }
91 95
 
92 96
 function verify {
@@ -133,7 +137,8 @@ function start {
133 137
     fi
134 138
     echo "info: enabling BMX6 mesh network $WIFI_SSID on $IFACE"
135 139
 
136
-    batman stop
140
+    mesh_protocol_stop
141
+
137 142
     systemctl stop network-manager
138 143
     sleep 5
139 144
 
@@ -207,6 +212,8 @@ function start {
207 212
     systemctl restart nginx
208 213
 
209 214
     verify
215
+
216
+    echo "bmx6" > $MESH_CURRENT_PROTOCOL
210 217
 }
211 218
 
212 219
 function monitor {

+ 19
- 0
src/freedombone-utils-mesh Ver arquivo

@@ -28,6 +28,25 @@
28 28
 # You should have received a copy of the GNU Affero General Public License
29 29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
30 30
 
31
+# File which contains the current protocol in use
32
+MESH_CURRENT_PROTOCOL=~/.mesh_protocol
33
+
34
+function mesh_protocol_stop {
35
+    if [ ! -f $MESH_CURRENT_PROTOCOL ]; then
36
+        return
37
+    fi
38
+
39
+    if grep -q "bmx6" $MESH_CURRENT_PROTOCOL; then
40
+        bmx stop
41
+    fi
42
+
43
+    if grep -q "batman-adv" $MESH_CURRENT_PROTOCOL; then
44
+        batman stop
45
+    fi
46
+
47
+    rm $MESH_CURRENT_PROTOCOL
48
+}
49
+
31 50
 function mesh_protocol_init {
32 51
     if [[ $1 == "start" ]]; then
33 52
         # install avahi