瀏覽代碼

Add bmx7 mesh protocol

Bob Mottram 7 年之前
父節點
當前提交
ea3b956829
共有 6 個檔案被更改,包括 451 行新增4 行删除
  1. 2
    0
      Makefile
  2. 98
    1
      src/freedombone-image-customise
  3. 4
    0
      src/freedombone-image-mesh
  4. 310
    0
      src/freedombone-mesh-bmx7
  5. 31
    2
      src/freedombone-mesh-reset
  6. 6
    1
      src/freedombone-utils-mesh

+ 2
- 0
Makefile 查看文件

29
 	cp src/* ${DESTDIR}${PREFIX}/bin
29
 	cp src/* ${DESTDIR}${PREFIX}/bin
30
 	cp src/${APP}-mesh-batman ${DESTDIR}${PREFIX}/bin/batman
30
 	cp src/${APP}-mesh-batman ${DESTDIR}${PREFIX}/bin/batman
31
 	cp src/${APP}-mesh-bmx6 ${DESTDIR}${PREFIX}/bin/bmx
31
 	cp src/${APP}-mesh-bmx6 ${DESTDIR}${PREFIX}/bin/bmx
32
+	cp src/${APP}-mesh-bmx7 ${DESTDIR}${PREFIX}/bin/bmxsec
32
 	cp src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup
33
 	cp src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup
33
 	cp src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup2friends
34
 	cp src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup2friends
34
 	cp src/${APP}-restore-local ${DESTDIR}${PREFIX}/bin/restore
35
 	cp src/${APP}-restore-local ${DESTDIR}${PREFIX}/bin/restore
62
 	rm -f ${PREFIX}/bin/restorefromfriend
63
 	rm -f ${PREFIX}/bin/restorefromfriend
63
 	rm -f ${PREFIX}/bin/batman
64
 	rm -f ${PREFIX}/bin/batman
64
 	rm -f ${PREFIX}/bin/bmx
65
 	rm -f ${PREFIX}/bin/bmx
66
+	rm -f ${PREFIX}/bin/bmxsec
65
 	rm -rf /etc/${APP}
67
 	rm -rf /etc/${APP}
66
 	rm -f ${PREFIX}/bin/control
68
 	rm -f ${PREFIX}/bin/control
67
 	rm -f ${PREFIX}/bin/controluser
69
 	rm -f ${PREFIX}/bin/controluser

+ 98
- 1
src/freedombone-image-customise 查看文件

128
 BMX6_REPO="https://github.com/bmx-routing/bmx6"
128
 BMX6_REPO="https://github.com/bmx-routing/bmx6"
129
 BMX6_COMMIT='39dd1f2d99ac5a3fa28e92f8173c15039132e181'
129
 BMX6_COMMIT='39dd1f2d99ac5a3fa28e92f8173c15039132e181'
130
 
130
 
131
+BMX7_REPO="https://github.com/bmx-routing/bmx7"
132
+BMX7_COMMIT='0a82c7c10fef44b259b35e77ab33632aa132d219'
133
+
131
 PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
134
 PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
132
 
135
 
133
 function configure_backports {
136
 function configure_backports {
644
 }
647
 }
645
 
648
 
646
 mesh_shutdown_script() {
649
 mesh_shutdown_script() {
650
+    mesh_shutdown_script=$rootdir/usr/bin/meshshutdown
651
+    echo '#!/bin/bash' > $mesh_shutdown_script
652
+    echo '' >> $mesh_shutdown_script
653
+    echo "if grep -q 'batman-adv' ${MESH_CURRENT_PROTOCOL}; then" >> $mesh_shutdown_script
654
+    echo '    batman stop' >> $mesh_shutdown_script
655
+    echo 'fi' >> $mesh_shutdown_script
656
+    echo '' >> $mesh_shutdown_script
657
+    echo "if grep -q 'bmx6' ${MESH_CURRENT_PROTOCOL}; then" >> $mesh_shutdown_script
658
+    echo '    bmx stop' >> $mesh_shutdown_script
659
+    echo 'fi' >> $mesh_shutdown_script
660
+    echo '' >> $mesh_shutdown_script
661
+    echo "if grep -q 'bmx7' ${MESH_CURRENT_PROTOCOL}; then" >> $mesh_shutdown_script
662
+    echo '    bmxsec stop' >> $mesh_shutdown_script
663
+    echo 'fi' >> $mesh_shutdown_script
664
+    chroot "$rootdir" chmod +x /usr/bin/meshshutdown
665
+
647
     echo '[Unit]' > $rootdir/etc/systemd/system/meshshutdown.service
666
     echo '[Unit]' > $rootdir/etc/systemd/system/meshshutdown.service
648
     echo 'Description=Shuts down the mesh' >> $rootdir/etc/systemd/system/meshshutdown.service
667
     echo 'Description=Shuts down the mesh' >> $rootdir/etc/systemd/system/meshshutdown.service
649
     echo 'Before=shutdown.target' >> $rootdir/etc/systemd/system/meshshutdown.service
668
     echo 'Before=shutdown.target' >> $rootdir/etc/systemd/system/meshshutdown.service
650
     echo '' >> $rootdir/etc/systemd/system/meshshutdown.service
669
     echo '' >> $rootdir/etc/systemd/system/meshshutdown.service
651
     echo '[Service]' >> $rootdir/etc/systemd/system/meshshutdown.service
670
     echo '[Service]' >> $rootdir/etc/systemd/system/meshshutdown.service
671
+    echo 'User=root' >> $rootdir/etc/systemd/system/meshshutdown.service
672
+    echo 'Group=root' >> $rootdir/etc/systemd/system/meshshutdown.service
652
     echo 'ExecStart=/bin/true' >> $rootdir/etc/systemd/system/meshshutdown.service
673
     echo 'ExecStart=/bin/true' >> $rootdir/etc/systemd/system/meshshutdown.service
653
-    echo 'ExecStop=/bin/bash /usr/local/bin/batman stop' >> $rootdir/etc/systemd/system/meshshutdown.service
674
+    echo 'ExecStop=/bin/bash /usr/bin/meshshutdown' >> $rootdir/etc/systemd/system/meshshutdown.service
654
     echo 'RemainAfterExit=yes' >> $rootdir/etc/systemd/system/meshshutdown.service
675
     echo 'RemainAfterExit=yes' >> $rootdir/etc/systemd/system/meshshutdown.service
655
     echo '' >> $rootdir/etc/systemd/system/meshshutdown.service
676
     echo '' >> $rootdir/etc/systemd/system/meshshutdown.service
656
     echo '[Install]' >> $rootdir/etc/systemd/system/meshshutdown.service
677
     echo '[Install]' >> $rootdir/etc/systemd/system/meshshutdown.service
700
         exit 79835292
721
         exit 79835292
701
     fi
722
     fi
702
 
723
 
724
+    rm $rootdir/usr/bin/install_bmx6
725
+
703
     echo '[Unit]' > $rootdir/etc/systemd/system/bmx6.service
726
     echo '[Unit]' > $rootdir/etc/systemd/system/bmx6.service
704
     echo 'Description=BMX6 mesh routing protocol' >> $rootdir/etc/systemd/system/bmx6.service
727
     echo 'Description=BMX6 mesh routing protocol' >> $rootdir/etc/systemd/system/bmx6.service
705
     echo 'Requires=network.target' >> $rootdir/etc/systemd/system/bmx6.service
728
     echo 'Requires=network.target' >> $rootdir/etc/systemd/system/bmx6.service
706
     echo 'After=network.target' >> $rootdir/etc/systemd/system/bmx6.service
729
     echo 'After=network.target' >> $rootdir/etc/systemd/system/bmx6.service
707
     echo '' >> $rootdir/etc/systemd/system/bmx6.service
730
     echo '' >> $rootdir/etc/systemd/system/bmx6.service
708
     echo '[Service]' >> $rootdir/etc/systemd/system/bmx6.service
731
     echo '[Service]' >> $rootdir/etc/systemd/system/bmx6.service
732
+    echo 'Type=forking' >> $rootdir/etc/systemd/system/bmx6.service
709
     echo 'User=root' >> $rootdir/etc/systemd/system/bmx6.service
733
     echo 'User=root' >> $rootdir/etc/systemd/system/bmx6.service
710
     echo 'Group=root' >> $rootdir/etc/systemd/system/bmx6.service
734
     echo 'Group=root' >> $rootdir/etc/systemd/system/bmx6.service
711
     echo 'ExecStart=/usr/sbin/bmx6 dev=wlan0' >> $rootdir/etc/systemd/system/bmx6.service
735
     echo 'ExecStart=/usr/sbin/bmx6 dev=wlan0' >> $rootdir/etc/systemd/system/bmx6.service
736
+    echo 'ExecStop=/usr/bin/kill -15 $MAINPID' >> $rootdir/etc/systemd/system/bmx6.service
737
+    echo 'PIDFile=/var/run/bmx6/pid' >> $rootdir/etc/systemd/system/bmx6.service
712
     echo 'Restart=on-failure' >> $rootdir/etc/systemd/system/bmx6.service
738
     echo 'Restart=on-failure' >> $rootdir/etc/systemd/system/bmx6.service
713
     echo '' >> $rootdir/etc/systemd/system/bmx6.service
739
     echo '' >> $rootdir/etc/systemd/system/bmx6.service
714
     echo '[Install]' >> $rootdir/etc/systemd/system/bmx6.service
740
     echo '[Install]' >> $rootdir/etc/systemd/system/bmx6.service
715
     echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/bmx6.service
741
     echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/bmx6.service
716
 }
742
 }
717
 
743
 
744
+install_bmx7() {
745
+    chroot "$rootdir" apt-get -qy install libjson-c-dev zlib1g-dev libiw-dev
746
+
747
+    git clone $BMX7_REPO $rootdir/etc/bmx7
748
+
749
+    cat <<EOF > $rootdir/usr/bin/install_bmx7
750
+#!/bin/bash
751
+cd /etc
752
+wget https://polarssl.org/code/releases/polarssl-1.3.3-gpl.tgz
753
+tar xzvf polarssl-1.3.3-gpl.tgz
754
+cd /etc/polarssl-1.3.3
755
+make
756
+sudo make install
757
+
758
+cd /etc/bmx7
759
+git checkout $BMX7_COMMIT -b $BMX7_COMMIT
760
+make EXTRA_CFLAGS="-DCRYPTLIB=POLARSSL_1_3_3"
761
+make install
762
+
763
+cd /etc/bmx7/lib/bmx7_http_info
764
+make
765
+make install
766
+
767
+cd /etc/bmx7/lib/bmx7_json
768
+make
769
+make install
770
+
771
+cd /etc/bmx7/lib/bmx7_tun
772
+make
773
+make install
774
+
775
+cd /etc/bmx7/lib/bmx7_sms
776
+make
777
+make install
778
+
779
+cd /etc/bmx7/lib/bmx7_topology
780
+make
781
+make install
782
+EOF
783
+    chroot "$rootdir" chmod +x /usr/bin/install_bmx7
784
+    chroot "$rootdir" /usr/bin/install_bmx7
785
+
786
+    if [ ! -f $rootdir/usr/sbin/bmx7 ]; then
787
+        echo $'bmx7 was not installed'
788
+        exit 67836235
789
+    fi
790
+
791
+    rm $rootdir/usr/bin/install_bmx7
792
+
793
+    echo '[Unit]' > $rootdir/etc/systemd/system/bmx7.service
794
+    echo 'Description=BMX7 mesh routing protocol' >> $rootdir/etc/systemd/system/bmx7.service
795
+    echo 'Requires=network.target' >> $rootdir/etc/systemd/system/bmx7.service
796
+    echo 'After=network.target' >> $rootdir/etc/systemd/system/bmx7.service
797
+    echo '' >> $rootdir/etc/systemd/system/bmx7.service
798
+    echo '[Service]' >> $rootdir/etc/systemd/system/bmx7.service
799
+    echo 'Type=forking' >> $rootdir/etc/systemd/system/bmx7.service
800
+    echo 'User=root' >> $rootdir/etc/systemd/system/bmx7.service
801
+    echo 'Group=root' >> $rootdir/etc/systemd/system/bmx7.service
802
+    echo 'ExecStart=/usr/sbin/bmx7 dev=wlan0' >> $rootdir/etc/systemd/system/bmx7.service
803
+    echo 'ExecStop=/usr/bin/kill -15 $MAINPID' >> $rootdir/etc/systemd/system/bmx7.service
804
+    echo 'PIDFile=/var/run/bmx6/pid' >> $rootdir/etc/systemd/system/bmx7.service
805
+    echo 'Restart=on-failure' >> $rootdir/etc/systemd/system/bmx7.service
806
+    echo '' >> $rootdir/etc/systemd/system/bmx7.service
807
+    echo '[Install]' >> $rootdir/etc/systemd/system/bmx7.service
808
+    echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/bmx7.service
809
+}
810
+
718
 initialise_mesh() {
811
 initialise_mesh() {
719
     if [[ $VARIANT != "mesh"* ]]; then
812
     if [[ $VARIANT != "mesh"* ]]; then
720
         return
813
         return
751
     # dhcp daemon for hotspot on secondary wifi adapter
844
     # dhcp daemon for hotspot on secondary wifi adapter
752
     chroot "$rootdir" apt-get -yq install dnsmasq
845
     chroot "$rootdir" apt-get -yq install dnsmasq
753
 
846
 
847
+    # set the default protocol to be used
848
+    echo 'batman-adv' > $rootdir$MESH_DEFAULT_PROTOCOL
849
+
754
     configure_firewall
850
     configure_firewall
755
     install_avahi
851
     install_avahi
756
     install_batman
852
     install_batman
757
     install_bmx6
853
     install_bmx6
854
+    install_bmx7
758
     mesh_shutdown_script
855
     mesh_shutdown_script
759
     install_vpn
856
     install_vpn
760
     install_tomb
857
     install_tomb

+ 4
- 0
src/freedombone-image-mesh 查看文件

1419
     systemctl disable bmx6
1419
     systemctl disable bmx6
1420
     echo $'BMX6 disabled' >> $INSTALL_LOG
1420
     echo $'BMX6 disabled' >> $INSTALL_LOG
1421
 
1421
 
1422
+    systemctl stop bmx7
1423
+    systemctl disable bmx7
1424
+    echo $'BMX7 disabled' >> $INSTALL_LOG
1425
+
1422
     #tomb slam all
1426
     #tomb slam all
1423
     tmp_ram_disk 100
1427
     tmp_ram_disk 100
1424
     enable_predictable_device_names
1428
     enable_predictable_device_names

+ 310
- 0
src/freedombone-mesh-bmx7 查看文件

1
+#!/bin/bash
2
+#
3
+# .---.                  .              .
4
+# |                      |              |
5
+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
+#
9
+#                    Freedom in the Cloud
10
+#
11
+# Used to enable or disable BMX7 mesh protocol on wlanX
12
+#
13
+# License
14
+# =======
15
+#
16
+# Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
17
+#
18
+# This program is free software: you can redistribute it and/or modify
19
+# it under the terms of the GNU Affero General Public License as published by
20
+# the Free Software Foundation, either version 3 of the License, or
21
+# (at your option) any later version.
22
+#
23
+# This program is distributed in the hope that it will be useful,
24
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
+# GNU Affero General Public License for more details.
27
+#
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/>.
30
+
31
+PROJECT_NAME='freedombone'
32
+COMPLETION_FILE=/root/${PROJECT_NAME}-completed.txt
33
+
34
+# hotspot passphrase must be 5 characters or longer
35
+HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
36
+
37
+source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
38
+source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
39
+
40
+mesh_protocol_init
41
+update_wifi_adaptors
42
+
43
+if [ ! $IFACE ]; then
44
+    echo $'No wlan adaptor'
45
+    exit 0
46
+fi
47
+
48
+function status {
49
+    bmx7 -c status
50
+}
51
+
52
+function stop {
53
+    if [ -z "$IFACE" ]; then
54
+        echo 'error: unable to find wifi interface, not enabling BMX7 mesh'
55
+        return
56
+    fi
57
+
58
+    systemctl stop dnsmasq
59
+    systemctl disable dnsmasq
60
+    systemctl stop bmx7
61
+    systemctl disable bmx7
62
+
63
+    if [ "$EIFACE" ]; then
64
+        ethernet_connected=$(cat /sys/class/net/$EIFACE/carrier)
65
+        if [[ "$ethernet_connected" != "0" ]]; then
66
+            systemctl stop hostapd
67
+            ifconfig $EIFACE down -promisc
68
+        fi
69
+    fi
70
+
71
+    avahi-autoipd -k $BRIDGE
72
+    avahi-autoipd -k $IFACE
73
+    ifconfig $IFACE down -promisc
74
+
75
+    ifconfig $IFACE mtu 1500
76
+    ifconfig $IFACE down
77
+    iwconfig $IFACE mode managed
78
+
79
+    if [ $IFACE_SECONDARY ]; then
80
+        systemctl stop hostapd
81
+        systemctl disable hostapd
82
+        ifconfig $IFACE_SECONDARY mtu 1500
83
+        ifconfig $IFACE_SECONDARY down
84
+        iwconfig $IFACE_SECONDARY mode managed
85
+    fi
86
+
87
+    disable_mesh_firewall
88
+
89
+    systemctl restart network-manager
90
+
91
+    if [ -f $MESH_CURRENT_PROTOCOL ]; then
92
+        rm $MESH_CURRENT_PROTOCOL
93
+    fi
94
+}
95
+
96
+function verify {
97
+    # TODO
98
+    echo -n ''
99
+}
100
+
101
+function add_wifi_interface {
102
+    ifname=$1
103
+    ifssid=$WIFI_SSID
104
+    if [ $2 ]; then
105
+        ifssid=$2
106
+    fi
107
+    ifmode=ad-hoc
108
+    if [ $3 ]; then
109
+        ifmode=$3
110
+    fi
111
+    ifchannel=$CHANNEL
112
+    if [ $4 ]; then
113
+        ifchannel=$4
114
+    fi
115
+
116
+    ifconfig $ifname down
117
+    ifconfig $ifname mtu 1500
118
+    peermac=$(assign_peer_address)
119
+    if [ ! $peermac ]; then
120
+        echo $"Unable to obtain MAC address for $peermac on $ifname"
121
+        return
122
+    fi
123
+    ifconfig $ifname hw ether $peermac
124
+    echo $"$ifname assigned MAC address $peermac"
125
+    iwconfig $ifname enc off
126
+    iwconfig $ifname mode $ifmode essid $ifssid channel $ifchannel
127
+
128
+    ifconfig $ifname up
129
+}
130
+
131
+function start {
132
+    update_wifi_adaptors
133
+
134
+    if [ -z "$IFACE" ] ; then
135
+        echo 'error: unable to find wifi interface, not enabling BMX7 mesh'
136
+        exit 723657
137
+    fi
138
+    echo "info: enabling BMX7 mesh network $WIFI_SSID on $IFACE"
139
+
140
+    mesh_protocol_stop
141
+
142
+    systemctl stop network-manager
143
+    sleep 5
144
+
145
+    systemctl stop dnsmasq
146
+    systemctl disable dnsmasq
147
+
148
+    # remove an avahi service which isn't used
149
+    if [ -f /etc/avahi/services/udisks.service ]; then
150
+        sudo rm /etc/avahi/services/udisks.service
151
+    fi
152
+
153
+    global_rate_limit
154
+
155
+    # Might have to re-enable wifi
156
+    rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true
157
+
158
+    secondary_wifi_available=
159
+    if [ $IFACE_SECONDARY ]; then
160
+        if [[ $IFACE != $IFACE_SECONDARY ]]; then
161
+            if [ -d /etc/hostapd ]; then
162
+                if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
163
+                    secondary_wifi_available=1
164
+                else
165
+                    echo $'Hotspot passphrase is too short'
166
+                fi
167
+            fi
168
+        fi
169
+    fi
170
+
171
+    add_wifi_interface $IFACE $WIFI_SSID ad-hoc $CHANNEL
172
+    ifconfig $IFACE up promisc
173
+
174
+    if [ ! $secondary_wifi_available ]; then
175
+        sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE}|g" /etc/systemd/system/bmx7.service
176
+    else
177
+        sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service
178
+    fi
179
+
180
+    systemctl daemon-reload
181
+    systemctl enable bmx7
182
+    systemctl start bmx7
183
+
184
+    avahi-autoipd --force-bind --daemonize --wait $IFACE
185
+
186
+    # NOTE: Don't connect the secondary wifi device. hostapd will handle that by itself
187
+
188
+    ethernet_connected='0'
189
+    if [ "$EIFACE" ] ; then
190
+        ethernet_connected=$(cat /sys/class/net/$EIFACE/carrier)
191
+        if [[ "$ethernet_connected" != "0" ]]; then
192
+            echo $'Trying ethernet bridge to the internet'
193
+            ifconfig $EIFACE up promisc
194
+            echo $'End of ethernet bridge'
195
+        else
196
+            echo $"$EIFACE is not connected"
197
+        fi
198
+    fi
199
+
200
+    enable_mesh_seconary_wifi
201
+
202
+    enable_mesh_firewall
203
+
204
+    systemctl restart avahi-daemon
205
+
206
+    enable_mesh_scuttlebot
207
+    enable_mesh_tor
208
+
209
+
210
+    sed -i "s|server_name .*|server_name ${HOSTNAME}.local;|g" /etc/nginx/sites-available/git_ssb
211
+
212
+    systemctl restart nginx
213
+
214
+    verify
215
+
216
+    echo "bmx7" > $MESH_CURRENT_PROTOCOL
217
+}
218
+
219
+function monitor {
220
+    if [ -z "$IFACE" ] ; then
221
+        echo 'error: unable to find wifi interface, not enabling BMX7 mesh'
222
+        exit 723657
223
+    fi
224
+
225
+    clear
226
+    echo ''
227
+    echo $'*** Stopping network ***'
228
+    echo ''
229
+
230
+    stop
231
+
232
+    echo "info: monitoring mesh network $WIFI_SSID on $IFACE"
233
+
234
+    systemctl stop network-manager
235
+    sleep 5
236
+
237
+    clear
238
+    echo ''
239
+    echo $'*** Setting firewall rate limit ***'
240
+    echo ''
241
+
242
+    global_rate_limit
243
+
244
+    clear
245
+    echo ''
246
+    echo $'*** Enabling wifi adaptor in monitor mode ***'
247
+    echo ''
248
+
249
+    # Might have to re-enable wifi
250
+    rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true
251
+
252
+    ifconfig $IFACE down
253
+    ifconfig $IFACE mtu 1500
254
+    ifconfig $IFACE hw ether $(assign_peer_address)
255
+    iwconfig $IFACE enc off
256
+    iwconfig $IFACE mode monitor channel $CHANNEL
257
+    sleep 1
258
+    iwconfig $IFACE ap $CELLID
259
+
260
+    ifconfig $IFACE up
261
+
262
+    horst -i $IFACE
263
+
264
+    clear
265
+    echo ''
266
+    echo $'*** Restarting the network daemon. This may take a while. ***'
267
+    echo ''
268
+
269
+    start
270
+}
271
+
272
+if ! grep -q "$IFACE" /proc/net/dev; then
273
+    echo 'Interface $IFACE was not found'
274
+    stop
275
+    exit 1
276
+fi
277
+
278
+case "$1" in
279
+    start|stop|status|monitor)
280
+        $1
281
+        ;;
282
+    restart)
283
+        clear
284
+        echo ''
285
+        echo $'*** Stopping BMX7 mesh network connection ***'
286
+        echo ''
287
+        stop
288
+        sleep 10
289
+        clear
290
+        echo ''
291
+        echo $'*** Starting BMX7 mesh network connection ***'
292
+        echo ''
293
+        start
294
+        ;;
295
+    ping)
296
+        ping $2
297
+        ;;
298
+    data)
299
+        bmx7 -lc traffic=$IFACE
300
+        ;;
301
+    ls|list)
302
+        avahi-browse -atl
303
+        ;;
304
+    *)
305
+        echo "error: invalid parameter $1"
306
+        echo 'usage: $0 {start|stop|restart|status|ping|ls|list}'
307
+        exit 2
308
+        ;;
309
+esac
310
+exit 0

+ 31
- 2
src/freedombone-mesh-reset 查看文件

31
 export TEXTDOMAIN=${PROJECT_NAME}-mesh-reset
31
 export TEXTDOMAIN=${PROJECT_NAME}-mesh-reset
32
 export TEXTDOMAINDIR="/usr/share/locale"
32
 export TEXTDOMAINDIR="/usr/share/locale"
33
 
33
 
34
+MESH_CURRENT_PROTOCOL=/root/.mesh_protocol
34
 MESH_INSTALL_COMPLETED=/root/.mesh_setup_completed
35
 MESH_INSTALL_COMPLETED=/root/.mesh_setup_completed
35
 
36
 
36
 if ! zenity --question --title=$'New Identity' --text=$"Do you want to reset your identity? This will reset ALL data for this peer, and you will not be able to recover it." --ok-label=No --cancel-label=Yes --width=300; then
37
 if ! zenity --question --title=$'New Identity' --text=$"Do you want to reset your identity? This will reset ALL data for this peer, and you will not be able to recover it." --ok-label=No --cancel-label=Yes --width=300; then
37
-    sudo batman stop
38
+
39
+    curr_protocol='batman-adv'
40
+    if grep -q "bmx6" $MESH_CURRENT_PROTOCOL; then
41
+        curr_protocol='bmx6'
42
+    fi
43
+    if grep -q "bmx7" $MESH_CURRENT_PROTOCOL; then
44
+        curr_protocol='bmx7'
45
+    fi
46
+
47
+    if [[ "$curr_protocol" == 'batman-adv' ]]; then
48
+        sudo batman stop
49
+    fi
50
+    if [[ "$curr_protocol" == 'bmx6' ]]; then
51
+        sudo bmx stop
52
+    fi
53
+    if [[ "$curr_protocol" == 'bmx7' ]]; then
54
+        sudo bmxsec stop
55
+    fi
56
+
38
     sudo pkill qtox
57
     sudo pkill qtox
39
     sudo pkill firefox
58
     sudo pkill firefox
40
     sudo pkill iceweasel
59
     sudo pkill iceweasel
42
     sudo pkill patchwork
61
     sudo pkill patchwork
43
     sudo rm -f $MESH_INSTALL_COMPLETED
62
     sudo rm -f $MESH_INSTALL_COMPLETED
44
     sudo ${PROJECT_NAME}-image-mesh $USER new
63
     sudo ${PROJECT_NAME}-image-mesh $USER new
45
-    sudo batman start
64
+
65
+    if [[ "$curr_protocol" == 'batman-adv' ]]; then
66
+        sudo batman start
67
+    fi
68
+    if [[ "$curr_protocol" == 'bmx6' ]]; then
69
+        sudo bmx start
70
+    fi
71
+    if [[ "$curr_protocol" == 'bmx7' ]]; then
72
+        sudo bmxsec start
73
+    fi
74
+
46
     if [ -f $HOME/mesh-desktop.sh ]; then
75
     if [ -f $HOME/mesh-desktop.sh ]; then
47
         $HOME/mesh-desktop.sh
76
         $HOME/mesh-desktop.sh
48
     else
77
     else

+ 6
- 1
src/freedombone-utils-mesh 查看文件

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
31
 # File which contains the current protocol in use
32
-MESH_CURRENT_PROTOCOL=~/.mesh_protocol
32
+MESH_CURRENT_PROTOCOL=/root/.mesh_protocol
33
+MESH_DEFAULT_PROTOCOL=/root/.mesh_protocol_default
33
 
34
 
34
 function mesh_protocol_stop {
35
 function mesh_protocol_stop {
35
     if [ ! -f $MESH_CURRENT_PROTOCOL ]; then
36
     if [ ! -f $MESH_CURRENT_PROTOCOL ]; then
40
         bmx stop
41
         bmx stop
41
     fi
42
     fi
42
 
43
 
44
+    if grep -q "bmx7" $MESH_CURRENT_PROTOCOL; then
45
+        bmxsec stop
46
+    fi
47
+
43
     if grep -q "batman-adv" $MESH_CURRENT_PROTOCOL; then
48
     if grep -q "batman-adv" $MESH_CURRENT_PROTOCOL; then
44
         batman stop
49
         batman stop
45
     fi
50
     fi