Преглед на файлове

Merge branch 'stretch' of https://github.com/bashrc/freedombone

Bob Mottram преди 7 години
родител
ревизия
fcff148f07

+ 34
- 4
src/freedombone-app-scuttlebot Целия файл

373
 #!/bin/bash
373
 #!/bin/bash
374
 npm install --arch=$NPM_ARCH -g dat
374
 npm install --arch=$NPM_ARCH -g dat
375
 npm install --arch=$NPM_ARCH -g @garbados/dat-boi
375
 npm install --arch=$NPM_ARCH -g @garbados/dat-boi
376
-npm install --arch=$NPM_ARCH -g add-to-systemd
377
-add-to-systemd dat-boi --user "$(whoami)" "$(which dat-boi)"
378
 EOF
376
 EOF
379
     chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
377
     chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
380
     chroot "$rootdir" /usr/bin/install_dat
378
     chroot "$rootdir" /usr/bin/install_dat
381
     rm "$rootdir/usr/bin/install_dat"
379
     rm "$rootdir/usr/bin/install_dat"
380
+
381
+    { echo '[Unit]';
382
+      echo 'Description=DAT-boi';
383
+      echo 'After=syslog.target';
384
+      echo 'After=network.target';
385
+      echo '';
386
+      echo '[Service]';
387
+      echo 'Type=simple';
388
+      echo 'User=root';
389
+      echo 'Group=root';
390
+      echo 'ExecStart=/usr/local/bin/dat-boi';
391
+      echo 'Restart=always';
392
+      echo '';
393
+      echo '[Install]';
394
+      echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/dat-boi.service"
395
+    chmod +x "$rootdir/etc/systemd/system/dat-boi.service"
396
+    chroot "$rootdir" systemctl enable dat-boi
382
 }
397
 }
383
 
398
 
384
 function install_dat {
399
 function install_dat {
385
     npm install -g dat
400
     npm install -g dat
386
     npm install -g @garbados/dat-boi
401
     npm install -g @garbados/dat-boi
387
-    npm install -g add-to-systemd
388
-    add-to-systemd dat-boi --user "$(whoami)" "$(which dat-boi)"
402
+
403
+    { echo '[Unit]';
404
+      echo 'Description=DAT-boi';
405
+      echo 'After=syslog.target';
406
+      echo 'After=network.target';
407
+      echo '';
408
+      echo '[Service]';
409
+      echo 'Type=simple';
410
+      echo 'User=root';
411
+      echo 'Group=root';
412
+      echo 'ExecStart=/usr/local/bin/dat-boi';
413
+      echo 'Restart=always';
414
+      echo '';
415
+      echo '[Install]';
416
+      echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/dat-boi.service
417
+    chmod +x /etc/systemd/system/dat-boi.service
418
+    systemctl enable dat-boi
389
 }
419
 }
390
 
420
 
391
 function mesh_install_scuttlebot {
421
 function mesh_install_scuttlebot {

+ 21
- 9
src/freedombone-image-customise Целия файл

143
 
143
 
144
 PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
144
 PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
145
 
145
 
146
-function configure_backports {
146
+configure_backports() {
147
     echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-backports main" >> "$rootdir/etc/apt/sources.list"
147
     echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-backports main" >> "$rootdir/etc/apt/sources.list"
148
 }
148
 }
149
 
149
 
150
-function configure_contrib_repo {
150
+configure_contrib_repo() {
151
     if ! grep -q "contrib" "$rootdir/etc/apt/sources.list"; then
151
     if ! grep -q "contrib" "$rootdir/etc/apt/sources.list"; then
152
         chroot "$rootdir" /bin/sed -i "s| main| main contrib|g" /etc/apt/sources.list
152
         chroot "$rootdir" /bin/sed -i "s| main| main contrib|g" /etc/apt/sources.list
153
     fi
153
     fi
973
         MESH_STARTUP_PARAMS="${MY_USERNAME} amnesic"
973
         MESH_STARTUP_PARAMS="${MY_USERNAME} amnesic"
974
     fi
974
     fi
975
 
975
 
976
+    # command to switch to wired mesh
977
+    { echo '#!/bin/bash';
978
+      echo 'echo -n "eth" > /root/.mesh_interface_type';
979
+      echo 'systemctl reboot -i'; } > "$rootdir/usr/bin/wired"
980
+    chmod +x "$rootdir/usr/bin/wired"
981
+
982
+    # command to switch to wireless mesh
983
+    { echo '#!/bin/bash';
984
+      echo 'echo -n "wlan" > /root/.mesh_interface_type';
985
+      echo 'systemctl reboot -i'; } > "$rootdir/usr/bin/wireless"
986
+    chmod +x "$rootdir/usr/bin/wireless"
987
+
976
     { echo '[Unit]';
988
     { echo '[Unit]';
977
       echo 'Description=Initial mesh router configuration';
989
       echo 'Description=Initial mesh router configuration';
978
       echo 'After=syslog.target';
990
       echo 'After=syslog.target';
995
 
1007
 
996
 # User interface for USB drive installs ######################################
1008
 # User interface for USB drive installs ######################################
997
 
1009
 
998
-function mesh_client_startup_applications {
1010
+mesh_client_startup_applications() {
999
     if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
1011
     if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
1000
         mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
1012
         mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
1001
     fi
1013
     fi
1074
     chmod +x "$START_DESKTOP2"
1086
     chmod +x "$START_DESKTOP2"
1075
 }
1087
 }
1076
 
1088
 
1077
-function mesh_desktop_icons {
1089
+mesh_desktop_icons() {
1078
     if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
1090
     if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
1079
         mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
1091
         mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
1080
     fi
1092
     fi
1092
     chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/Desktop"
1104
     chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/Desktop"
1093
 }
1105
 }
1094
 
1106
 
1095
-function configure_user_interface {
1107
+configure_user_interface() {
1096
     if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" && "$VARIANT" != "usb" ]]; then
1108
     if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" && "$VARIANT" != "usb" ]]; then
1097
         return
1109
         return
1098
     fi
1110
     fi
1630
 # setup_utils
1642
 # setup_utils
1631
 ##############################################################################
1643
 ##############################################################################
1632
 
1644
 
1633
-function image_install_inadyn {
1645
+image_install_inadyn() {
1634
     if [ "$INSTALLING_MESH" ]; then
1646
     if [ "$INSTALLING_MESH" ]; then
1635
         return
1647
         return
1636
     fi
1648
     fi
1693
     echo "inadyn commit:$INADYN_COMMIT" >> "$rootdir/root/freedombone-completed.txt"
1705
     echo "inadyn commit:$INADYN_COMMIT" >> "$rootdir/root/freedombone-completed.txt"
1694
 }
1706
 }
1695
 
1707
 
1696
-function image_setup_utils {
1708
+image_setup_utils() {
1697
     if [ "$INSTALLING_MESH" ]; then
1709
     if [ "$INSTALLING_MESH" ]; then
1698
         return
1710
         return
1699
     fi
1711
     fi
1881
     #sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' $rootdir/etc/fstab
1893
     #sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' $rootdir/etc/fstab
1882
 }
1894
 }
1883
 
1895
 
1884
-function image_install_nodejs {
1896
+image_install_nodejs() {
1885
     mesh_install_nodejs
1897
     mesh_install_nodejs
1886
     #echo 'install_nodejs' >> ${rootdir}/root/${PROJECT_NAME}-completed.txt
1898
     #echo 'install_nodejs' >> ${rootdir}/root/${PROJECT_NAME}-completed.txt
1887
 }
1899
 }
1888
 
1900
 
1889
-function image_preinstall_repos {
1901
+image_preinstall_repos() {
1890
     if [[ "$VARIANT" == "mesh"* ]]; then
1902
     if [[ "$VARIANT" == "mesh"* ]]; then
1891
         return
1903
         return
1892
     fi
1904
     fi

+ 2
- 2
src/freedombone-image-make Целия файл

193
 echo $'Changing values within customised customisation script'
193
 echo $'Changing values within customised customisation script'
194
 cp "$PROJECT_INSTALL_DIR/${PROJECT_NAME}-image-customise" "$TEMP_CUSTOMISE3"
194
 cp "$PROJECT_INSTALL_DIR/${PROJECT_NAME}-image-customise" "$TEMP_CUSTOMISE3"
195
 if [ "$MYUSERNAME" ]; then
195
 if [ "$MYUSERNAME" ]; then
196
-    sed -i "s|MY_USERNAME=.*|MY_USERNAME=${MYUSERNAME}|g" "$TEMP_CUSTOMISE3"
196
+    sed -i "0,/MY_USERNAME=.*/s//MY_USERNAME=${MYUSERNAME}/" "$TEMP_CUSTOMISE3"
197
 fi
197
 fi
198
 if [ "$MYPASSWORD" ]; then
198
 if [ "$MYPASSWORD" ]; then
199
     sed -i "s|MY_PASSWORD=.*|MY_PASSWORD=${MYPASSWORD}|g" "$TEMP_CUSTOMISE3"
199
     sed -i "s|MY_PASSWORD=.*|MY_PASSWORD=${MYPASSWORD}|g" "$TEMP_CUSTOMISE3"
211
 sed -i "s|SSH_PUBKEY=.*|SSH_PUBKEY=${SSH_PUBKEY}|g" "$TEMP_CUSTOMISE3"
211
 sed -i "s|SSH_PUBKEY=.*|SSH_PUBKEY=${SSH_PUBKEY}|g" "$TEMP_CUSTOMISE3"
212
 sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" "$TEMP_CUSTOMISE3"
212
 sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" "$TEMP_CUSTOMISE3"
213
 sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" "$TEMP_CUSTOMISE3"
213
 sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" "$TEMP_CUSTOMISE3"
214
-sed -i "s|SSH_PORT=.*|SSH_PORT=\"${SSH_PORT}\"|g" "$TEMP_CUSTOMISE3"
214
+sed -i "0,/SSH_PORT=.*/s//SSH_PORT=\"${SSH_PORT}\"/" "$TEMP_CUSTOMISE3"
215
 sed -i "s|ONION_ONLY=.*|ONION_ONLY=\"${ONION_ONLY}\"|g" "$TEMP_CUSTOMISE3"
215
 sed -i "s|ONION_ONLY=.*|ONION_ONLY=\"${ONION_ONLY}\"|g" "$TEMP_CUSTOMISE3"
216
 sed -i "s|PROJECT_REPO=.*|PROJECT_REPO=\"${PROJECT_REPO}\"|g" "$TEMP_CUSTOMISE3"
216
 sed -i "s|PROJECT_REPO=.*|PROJECT_REPO=\"${PROJECT_REPO}\"|g" "$TEMP_CUSTOMISE3"
217
 sed -i "s|DEBIAN_INSTALL_ONLY=.*|DEBIAN_INSTALL_ONLY=\"${DEBIAN_INSTALL_ONLY}\"|g" "$TEMP_CUSTOMISE3"
217
 sed -i "s|DEBIAN_INSTALL_ONLY=.*|DEBIAN_INSTALL_ONLY=\"${DEBIAN_INSTALL_ONLY}\"|g" "$TEMP_CUSTOMISE3"

+ 84
- 49
src/freedombone-mesh-batman Целия файл

8
 #
8
 #
9
 #                    Freedom in the Cloud
9
 #                    Freedom in the Cloud
10
 #
10
 #
11
-# Used to enable or disable batman mesh protocol on wlanX
11
+# Used to enable or disable batman mesh protocol on a given interface
12
 #
12
 #
13
 # License
13
 # License
14
 # =======
14
 # =======
34
 # hotspot passphrase must be 5 characters or longer
34
 # hotspot passphrase must be 5 characters or longer
35
 HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
35
 HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
36
 
36
 
37
+# The type of interface which the mesh will run on
38
+MESH_INTERFACE_TYPE='wlan'
39
+
37
 source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
40
 source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
38
 source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
41
 source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
39
 
42
 
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
-if [ -e /etc/default/batctl ]; then
49
-    # shellcheck disable=SC1091
50
-    . /etc/default/batctl
51
-fi
52
-
53
 function status {
43
 function status {
54
     batctl o
44
     batctl o
55
 
45
 
84
 
74
 
85
     # shellcheck disable=SC2153
75
     # shellcheck disable=SC2153
86
     if [ "$EIFACE" ]; then
76
     if [ "$EIFACE" ]; then
87
-        brctl delif "$BRIDGE" bat0
88
-        ifconfig "$BRIDGE" down || true
89
-        ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
90
-        if [[ "$ethernet_connected" != "0" ]]; then
91
-            systemctl stop hostapd
92
-            brctl delif "$BRIDGE" "$EIFACE"
93
-            ifconfig "$EIFACE" down -promisc
77
+        if [[ "$EIFACE" != "$IFACE" ]] ; then
78
+            brctl delif "$BRIDGE" bat0
79
+            ifconfig "$BRIDGE" down || true
80
+            ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
81
+            if [[ "$ethernet_connected" != "0" ]]; then
82
+                systemctl stop hostapd
83
+                brctl delif "$BRIDGE" "$EIFACE"
84
+                ifconfig "$EIFACE" down -promisc
85
+            fi
86
+            brctl delbr "$BRIDGE"
94
         fi
87
         fi
95
-        brctl delbr "$BRIDGE"
96
     fi
88
     fi
97
 
89
 
98
     ifconfig bat0 down -promisc
90
     ifconfig bat0 down -promisc
100
     batctl if del "$IFACE"
92
     batctl if del "$IFACE"
101
     ifconfig "$IFACE" mtu 1500
93
     ifconfig "$IFACE" mtu 1500
102
     ifconfig "$IFACE" down
94
     ifconfig "$IFACE" down
103
-    iwconfig "$IFACE" mode managed
95
+    if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
96
+        iwconfig "$IFACE" mode managed
97
+    fi
104
 
98
 
105
     if [ "$IFACE_SECONDARY" ]; then
99
     if [ "$IFACE_SECONDARY" ]; then
106
         systemctl stop hostapd
100
         systemctl stop hostapd
108
         batctl if del "$IFACE_SECONDARY"
102
         batctl if del "$IFACE_SECONDARY"
109
         ifconfig "$IFACE_SECONDARY" mtu 1500
103
         ifconfig "$IFACE_SECONDARY" mtu 1500
110
         ifconfig "$IFACE_SECONDARY" down
104
         ifconfig "$IFACE_SECONDARY" down
111
-        iwconfig "$IFACE_SECONDARY" mode managed
105
+        if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
106
+            iwconfig "$IFACE_SECONDARY" mode managed
107
+        fi
112
     fi
108
     fi
113
 
109
 
114
     rmmod batman-adv
110
     rmmod batman-adv
159
     fi
155
     fi
160
     ifconfig "$ifname" hw ether "$peermac"
156
     ifconfig "$ifname" hw ether "$peermac"
161
     echo $"$ifname assigned MAC address $peermac"
157
     echo $"$ifname assigned MAC address $peermac"
162
-    iwconfig "$ifname" enc off
163
-    iwconfig "$ifname" mode "$ifmode" essid "$ifssid" channel "$ifchannel"
158
+    if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
159
+        iwconfig "$ifname" enc off
160
+        iwconfig "$ifname" mode "$ifmode" essid "$ifssid" channel "$ifchannel"
161
+    fi
164
 
162
 
165
     batctl if add "$ifname"
163
     batctl if add "$ifname"
166
     ifconfig "$ifname" up
164
     ifconfig "$ifname" up
168
 
166
 
169
 # shellcheck disable=SC2120
167
 # shellcheck disable=SC2120
170
 function start {
168
 function start {
171
-    update_wifi_adaptors
169
+    update_wifi_adaptors "${MESH_INTERFACE_TYPE}"
172
 
170
 
173
     if [ -z "$IFACE" ] ; then
171
     if [ -z "$IFACE" ] ; then
174
         echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
172
         echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
194
     rfkill unblock "$(rfkill list|awk -F: "/phy/ {print $1}")" || true
192
     rfkill unblock "$(rfkill list|awk -F: "/phy/ {print $1}")" || true
195
 
193
 
196
     secondary_wifi_available=
194
     secondary_wifi_available=
197
-    if [ "$IFACE_SECONDARY" ]; then
198
-        if [[ "$IFACE" != "$IFACE_SECONDARY" ]]; then
199
-            if [ -d /etc/hostapd ]; then
200
-                if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
201
-                    secondary_wifi_available=1
202
-                else
203
-                    echo $'Hotspot passphrase is too short'
195
+    if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
196
+        if [ "$IFACE_SECONDARY" ]; then
197
+            if [[ "$IFACE" != "$IFACE_SECONDARY" ]]; then
198
+                if [ -d /etc/hostapd ]; then
199
+                    if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
200
+                        secondary_wifi_available=1
201
+                    else
202
+                        echo $'Hotspot passphrase is too short'
203
+                    fi
204
                 fi
204
                 fi
205
             fi
205
             fi
206
         fi
206
         fi
229
     ifconfig bat0 0.0.0.0
229
     ifconfig bat0 0.0.0.0
230
     ethernet_connected='0'
230
     ethernet_connected='0'
231
     if [ "$EIFACE" ] ; then
231
     if [ "$EIFACE" ] ; then
232
-        ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
233
-        if [[ "$ethernet_connected" != "0" ]]; then
234
-            echo $'Trying ethernet bridge to the internet'
235
-            brctl addif "$BRIDGE" "$EIFACE"
236
-            ifconfig "$EIFACE" 0.0.0.0
237
-            ifconfig "$EIFACE" up promisc
238
-            echo $'End of ethernet bridge'
239
-
240
-            sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx6.service
241
-            sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service
242
-            sed -i "s|ExecStart=.*|ExecStart=/usr/local/sbin/olsrd2_static ${IFACE} ${EIFACE}|g" /etc/systemd/system/olsr2.service
243
-            sed -i "s|ExecStart=.*|ExecStart=/usr/local/bin/babeld ${IFACE} ${EIFACE}|g" /etc/systemd/system/babel.service
244
-            systemctl daemon-reload
245
-        else
246
-            echo $"$EIFACE is not connected"
232
+        if [[ "$EIFACE" != "$IFACE" ]] ; then
233
+            ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
234
+            if [[ "$ethernet_connected" != "0" ]]; then
235
+                echo $'Trying ethernet bridge to the internet'
236
+                brctl addif "$BRIDGE" "$EIFACE"
237
+                ifconfig "$EIFACE" 0.0.0.0
238
+                ifconfig "$EIFACE" up promisc
239
+                echo $'End of internet bridge'
240
+
241
+                sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx6.service
242
+                sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service
243
+                sed -i "s|ExecStart=.*|ExecStart=/usr/local/sbin/olsrd2_static ${IFACE} ${EIFACE}|g" /etc/systemd/system/olsr2.service
244
+                sed -i "s|ExecStart=.*|ExecStart=/usr/local/bin/babeld ${IFACE} ${EIFACE}|g" /etc/systemd/system/babel.service
245
+                systemctl daemon-reload
246
+            else
247
+                echo $"$EIFACE is not connected"
248
+            fi
247
         fi
249
         fi
248
     fi
250
     fi
249
     ifconfig "$BRIDGE" up
251
     ifconfig "$BRIDGE" up
302
 }
304
 }
303
 
305
 
304
 function monitor {
306
 function monitor {
307
+    if [[ "$MESH_INTERFACE_TYPE" != 'wlan'* ]]; then
308
+        return
309
+    fi
305
     if [ -z "$IFACE" ] ; then
310
     if [ -z "$IFACE" ] ; then
306
         echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
311
         echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
307
         exit 723657
312
         exit 723657
357
     start
362
     start
358
 }
363
 }
359
 
364
 
365
+# optionally a file can contain the mesh interface type
366
+mesh_interface_type_file=/root/.mesh_interface_type
367
+if [ -f "$mesh_interface_type_file" ]; then
368
+    MESH_INTERFACE_TYPE=$(head -n 1 < "$mesh_interface_type_file")
369
+    if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
370
+        MESH_INTERFACE_TYPE='wlan'
371
+    fi
372
+    if [[ "$MESH_INTERFACE_TYPE" == 'eth'* ]]; then
373
+        MESH_INTERFACE_TYPE='eth'
374
+    fi
375
+fi
376
+
377
+mesh_protocol_init
378
+
379
+if [[ "$MESH_INTERFACE_TYPE" == 'eth'* ]]; then
380
+    MESH_INTERFACE_TYPE='eth'
381
+fi
382
+
383
+update_wifi_adaptors "${MESH_INTERFACE_TYPE}"
384
+
385
+if [ ! "$IFACE" ]; then
386
+    echo $'No wlan adaptor'
387
+    exit 0
388
+fi
389
+
390
+if [ -e /etc/default/batctl ]; then
391
+    # shellcheck disable=SC1091
392
+    . /etc/default/batctl
393
+fi
394
+
360
 if ! grep -q "$IFACE" /proc/net/dev; then
395
 if ! grep -q "$IFACE" /proc/net/dev; then
361
     echo "Interface \$IFACE was not found"
396
     echo "Interface \$IFACE was not found"
362
     stop
397
     stop

+ 4
- 4
src/freedombone-utils-avahi Целия файл

65
     sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" "$rootdir/etc/avahi/avahi-daemon.conf"
65
     sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" "$rootdir/etc/avahi/avahi-daemon.conf"
66
     sed -i "s|use-ipv4=.*|use-ipv4=no|g" "$rootdir/etc/avahi/avahi-daemon.conf"
66
     sed -i "s|use-ipv4=.*|use-ipv4=no|g" "$rootdir/etc/avahi/avahi-daemon.conf"
67
     sed -i "s|use-ipv6=.*|use-ipv6=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
67
     sed -i "s|use-ipv6=.*|use-ipv6=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
68
-    sed -i "s|#allow-interfaces=.*|allow-interfaces=wlan0, wlan1, wlan2, wlan3, wlan4, wlan5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
69
-    sed -i "s|allow-interfaces=.*|allow-interfaces=wlan0, wlan1, wlan2, wlan3, wlan4, wlan5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
70
-    sed -i "s|#deny-interfaces=.*|deny-interfaces=eth0, eth1, eth2, eth3, eth4, eth5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
71
-    sed -i "s|deny-interfaces=.*|deny-interfaces=eth0, eth1, eth2, eth3, eth4, eth5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
68
+    #sed -i "s|#allow-interfaces=.*|allow-interfaces=wlan0, wlan1, wlan2, wlan3, wlan4, wlan5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
69
+    #sed -i "s|allow-interfaces=.*|allow-interfaces=wlan0, wlan1, wlan2, wlan3, wlan4, wlan5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
70
+    #sed -i "s|#deny-interfaces=.*|deny-interfaces=eth0, eth1, eth2, eth3, eth4, eth5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
71
+    #sed -i "s|deny-interfaces=.*|deny-interfaces=eth0, eth1, eth2, eth3, eth4, eth5|g" "$rootdir/etc/avahi/avahi-daemon.conf"
72
     sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
72
     sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
73
     sed -i "s|disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
73
     sed -i "s|disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
74
     sed -i "s|#publish_addresses=.*|publish_addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
74
     sed -i "s|#publish_addresses=.*|publish_addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"

+ 6
- 4
src/freedombone-utils-mesh Целия файл

99
     IFACE=
99
     IFACE=
100
     IFACE_SECONDARY=
100
     IFACE_SECONDARY=
101
     EIFACE=eth0
101
     EIFACE=eth0
102
-    WLAN_ADAPTORS=$(count_wlan)
102
+    if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
103
+        WLAN_ADAPTORS=$(count_wlan)
103
 
104
 
104
-    if [ "$WLAN_ADAPTORS" -eq 0 ]; then
105
-        echo $'No wlan adaptors found'
106
-        exit 0
105
+        if [ "$WLAN_ADAPTORS" -eq 0 ]; then
106
+            echo $'No wlan adaptors found'
107
+            exit 0
108
+        fi
107
     fi
109
     fi
108
 }
110
 }
109
 
111
 

+ 10
- 5
src/freedombone-utils-wifi Целия файл

100
     fi
100
     fi
101
     dpkg -i "$atheros_drivers_file"
101
     dpkg -i "$atheros_drivers_file"
102
     reset_usb_devices
102
     reset_usb_devices
103
-    update_wifi_adaptors
103
+    update_wifi_adaptors 'wlan'
104
     if [ "$IFACE" ]; then
104
     if [ "$IFACE" ]; then
105
         wpa_action "${IFACE}" stop
105
         wpa_action "${IFACE}" stop
106
         wpa_cli -i "${IFACE}" terminate
106
         wpa_cli -i "${IFACE}" terminate
198
 }
198
 }
199
 
199
 
200
 function update_wifi_adaptors {
200
 function update_wifi_adaptors {
201
+    interface_type="$1"
201
     IFACE=
202
     IFACE=
202
     IFACE_SECONDARY=
203
     IFACE_SECONDARY=
203
 
204
 
205
+    if [ ! "$interface_type" ]; then
206
+        interface_type='wlan'
207
+    fi
208
+
204
     for i in $(seq 10 -1 0); do
209
     for i in $(seq 10 -1 0); do
205
-        ifdown --force "wlan${i}" 2> /dev/null
210
+        ifdown --force "${interface_type}${i}" 2> /dev/null
206
     done
211
     done
207
 
212
 
208
     for i in $(seq 10 -1 0); do
213
     for i in $(seq 10 -1 0); do
209
-        if grep -q "wlan${i}" /proc/net/dev; then
214
+        if grep -q "${interface_type}${i}" /proc/net/dev; then
210
             if [ ! $IFACE ]; then
215
             if [ ! $IFACE ]; then
211
                 IFACE="wlan${i}"
216
                 IFACE="wlan${i}"
212
             else
217
             else
213
-                IFACE_SECONDARY="wlan${i}"
218
+                IFACE_SECONDARY="${interface_type}${i}"
214
                 return
219
                 return
215
             fi
220
             fi
216
         fi
221
         fi
479
 
484
 
480
 function create_networks_interactive {
485
 function create_networks_interactive {
481
     remove_config_param "WIFI_INTERFACE"
486
     remove_config_param "WIFI_INTERFACE"
482
-    update_wifi_adaptors
487
+    update_wifi_adaptors 'wlan'
483
     if [ ! "$IFACE" ]; then
488
     if [ ! "$IFACE" ]; then
484
         # Don't try to configure wifi if there are no adaptors
489
         # Don't try to configure wifi if there are no adaptors
485
         return
490
         return

+ 1
- 1
src/freedombone-wifi Целия файл

150
     else
150
     else
151
         sleep "${WAIT_SEC}"
151
         sleep "${WAIT_SEC}"
152
     fi
152
     fi
153
-    update_wifi_adaptors
153
+    update_wifi_adaptors 'wlan'
154
     if [ ! $IFACE ]; then
154
     if [ ! $IFACE ]; then
155
         echo $'No wifi adaptors were found'
155
         echo $'No wifi adaptors were found'
156
         exit 872356
156
         exit 872356