Bläddra i källkod

Stopping mesh protocol before starting another

Bob Mottram 7 år sedan
förälder
incheckning
4b19fc06ea
3 ändrade filer med 35 tillägg och 1 borttagningar
  1. 8
    0
      src/freedombone-mesh-batman
  2. 8
    1
      src/freedombone-mesh-bmx6
  3. 19
    0
      src/freedombone-utils-mesh

+ 8
- 0
src/freedombone-mesh-batman Visa fil

97
     disable_mesh_firewall
97
     disable_mesh_firewall
98
 
98
 
99
     systemctl restart network-manager
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
 function verify {
106
 function verify {
152
     fi
156
     fi
153
     echo "info: enabling batman-adv mesh network $WIFI_SSID on $IFACE"
157
     echo "info: enabling batman-adv mesh network $WIFI_SSID on $IFACE"
154
 
158
 
159
+    mesh_protocol_stop
160
+
155
     systemctl stop network-manager
161
     systemctl stop network-manager
156
     sleep 5
162
     sleep 5
157
 
163
 
225
     systemctl restart nginx
231
     systemctl restart nginx
226
 
232
 
227
     verify
233
     verify
234
+
235
+    echo "batman-adv" > $MESH_CURRENT_PROTOCOL
228
 }
236
 }
229
 
237
 
230
 function monitor {
238
 function monitor {

+ 8
- 1
src/freedombone-mesh-bmx6 Visa fil

87
     disable_mesh_firewall
87
     disable_mesh_firewall
88
 
88
 
89
     systemctl restart network-manager
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
 function verify {
96
 function verify {
133
     fi
137
     fi
134
     echo "info: enabling BMX6 mesh network $WIFI_SSID on $IFACE"
138
     echo "info: enabling BMX6 mesh network $WIFI_SSID on $IFACE"
135
 
139
 
136
-    batman stop
140
+    mesh_protocol_stop
141
+
137
     systemctl stop network-manager
142
     systemctl stop network-manager
138
     sleep 5
143
     sleep 5
139
 
144
 
207
     systemctl restart nginx
212
     systemctl restart nginx
208
 
213
 
209
     verify
214
     verify
215
+
216
+    echo "bmx6" > $MESH_CURRENT_PROTOCOL
210
 }
217
 }
211
 
218
 
212
 function monitor {
219
 function monitor {

+ 19
- 0
src/freedombone-utils-mesh Visa fil

28
 # You should have received a copy of the GNU Affero General Public License
28
 # You should have received a copy of the GNU Affero General Public License
29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
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
 function mesh_protocol_init {
50
 function mesh_protocol_init {
32
     if [[ $1 == "start" ]]; then
51
     if [[ $1 == "start" ]]; then
33
         # install avahi
52
         # install avahi