Kaynağa Gözat

utils should only contain functions

Bob Mottram 7 yıl önce
ebeveyn
işleme
f7dca26bd3

+ 1
- 0
src/freedombone-mesh-batman Dosyayı Görüntüle

@@ -37,6 +37,7 @@ HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
37 37
 source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
38 38
 source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
39 39
 
40
+mesh_protocol_init
40 41
 update_wifi_adaptors
41 42
 
42 43
 if [ ! $IFACE ]; then

+ 1
- 0
src/freedombone-mesh-bmx6 Dosyayı Görüntüle

@@ -37,6 +37,7 @@ HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
37 37
 source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
38 38
 source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
39 39
 
40
+mesh_protocol_init
40 41
 update_wifi_adaptors
41 42
 
42 43
 if [ ! $IFACE ]; then

+ 45
- 43
src/freedombone-utils-mesh Dosyayı Görüntüle

@@ -28,56 +28,58 @@
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
-if [[ $1 == "start" ]]; then
32
-    # install avahi
33
-    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf
34
-    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf
35
-    sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf
36
-    sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf
37
-    sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" /etc/avahi/avahi-daemon.conf
38
-    sed -i "s|hosts:.*|hosts:          files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf
39
-fi
31
+function mesh_protocol_init {
32
+    if [[ $1 == "start" ]]; then
33
+        # install avahi
34
+        sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf
35
+        sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf
36
+        sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf
37
+        sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf
38
+        sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" /etc/avahi/avahi-daemon.conf
39
+        sed -i "s|hosts:.*|hosts:          files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf
40
+    fi
40 41
 
41
-# Mesh definition
42
-WIFI_SSID='mesh'
43
-if [ -f $COMPLETION_FILE ]; then
44
-    if grep -q "WIFI_SSID:" $COMPLETION_FILE; then
45
-        WIFI_SSID=$(cat $COMPLETION_FILE | grep "WIFI_SSID:" | awk -F ':' '{print $2}')
42
+    # Mesh definition
43
+    WIFI_SSID='mesh'
44
+    if [ -f $COMPLETION_FILE ]; then
45
+        if grep -q "WIFI_SSID:" $COMPLETION_FILE; then
46
+            WIFI_SSID=$(cat $COMPLETION_FILE | grep "WIFI_SSID:" | awk -F ':' '{print $2}')
47
+        fi
48
+        sed -i "s|WIFI_SSID:.*|WIFI_SSID:${WIFI_SSID}|g" $COMPLETION_FILE
46 49
     fi
47
-    sed -i "s|WIFI_SSID:.*|WIFI_SSID:${WIFI_SSID}|g" $COMPLETION_FILE
48
-fi
49
-CELLID='any'
50
+    CELLID='any'
50 51
 
51
-CHANNEL=2
52
-HOTSPOT_CHANNEL=6
53
-if [ -f $COMPLETION_FILE ]; then
54
-    if grep -q "Wifi channel:" $COMPLETION_FILE; then
55
-        CHANNEL=$(cat $COMPLETION_FILE | grep "Wifi channel:" | awk -F ':' '{print $2}')
52
+    CHANNEL=2
53
+    HOTSPOT_CHANNEL=6
54
+    if [ -f $COMPLETION_FILE ]; then
55
+        if grep -q "Wifi channel:" $COMPLETION_FILE; then
56
+            CHANNEL=$(cat $COMPLETION_FILE | grep "Wifi channel:" | awk -F ':' '{print $2}')
57
+        fi
58
+        sed -i "s|Wifi channel:.*|Wifi channel:${CHANNEL}|g" $COMPLETION_FILE
56 59
     fi
57
-    sed -i "s|Wifi channel:.*|Wifi channel:${CHANNEL}|g" $COMPLETION_FILE
58
-fi
59 60
 
60
-ZERONET_PORT=15441
61
-IPFS_PORT=4001
62
-TOX_PORT=33445
63
-TRACKER_PORT=6969
64
-LIBREVAULT_PORT=42345
65
-TAHOELAFS_PORT=50213
66
-GIT_SSB_PORT=7718
67
-NGINX_GIT_SSB_PORT=7719
61
+    ZERONET_PORT=15441
62
+    IPFS_PORT=4001
63
+    TOX_PORT=33445
64
+    TRACKER_PORT=6969
65
+    LIBREVAULT_PORT=42345
66
+    TAHOELAFS_PORT=50213
67
+    GIT_SSB_PORT=7718
68
+    NGINX_GIT_SSB_PORT=7719
68 69
 
69
-# Ethernet bridge definition (bridged to bat0)
70
-BRIDGE=br-mesh
71
-BRIDGE_HOTSPOT=br-hotspot
72
-IFACE=
73
-IFACE_SECONDARY=
74
-EIFACE=eth0
75
-WLAN_ADAPTORS=$(count_wlan)
70
+    # Ethernet bridge definition (bridged to bat0)
71
+    BRIDGE=br-mesh
72
+    BRIDGE_HOTSPOT=br-hotspot
73
+    IFACE=
74
+    IFACE_SECONDARY=
75
+    EIFACE=eth0
76
+    WLAN_ADAPTORS=$(count_wlan)
76 77
 
77
-if [ $WLAN_ADAPTORS -eq 0 ]; then
78
-    echo $'No wlan adaptors found'
79
-    exit 0
80
-fi
78
+    if [ $WLAN_ADAPTORS -eq 0 ]; then
79
+        echo $'No wlan adaptors found'
80
+        exit 0
81
+    fi
82
+}
81 83
 
82 84
 function get_ipv4_wlan {
83 85
     echo $(ip -o -f inet addr show dev "$IFACE" | awk '{print $4}' | awk 'END {print}' | awk -F '/' '{print $1}')