浏览代码

Only enable scuttlebot on mesh gateways

Bob Mottram 7 年前
父节点
当前提交
5865f2633d
共有 3 个文件被更改,包括 35 次插入12 次删除
  1. 28
    0
      src/freedombone-image-customise
  2. 0
    10
      src/freedombone-image-mesh
  3. 7
    2
      src/freedombone-mesh-batman

+ 28
- 0
src/freedombone-image-customise 查看文件

@@ -894,6 +894,7 @@ function configure_user_interface {
894 894
     # Produce a text file on the desktop listing users on the mesh
895 895
     cat <<EOF > $rootdir/usr/bin/list-tox-users
896 896
 #!/bin/bash
897
+ethernet_connected=$(cat /sys/class/net/eth0/carrier)
897 898
 users_list=\$(lstox | awk -F ' ' '{\$1=""; print \$0}' | sed -e 's/^[[:space:]]*//' | sort -d | uniq)
898 899
 if [ ! \$users_list ]; then
899 900
     no_of_users=0
@@ -1003,6 +1004,26 @@ if [ \$no_of_users -gt 0 ]; then
1003 1004
         chmod +x /home/$MY_USERNAME/Desktop/tox.desktop
1004 1005
         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/tox.desktop
1005 1006
     fi
1007
+
1008
+    # If ethernet is connected then add the invite icon to help enable
1009
+    # SSB nat traversal
1010
+    if [[ "$ethernet_connected" != "0" ]]; then
1011
+        if [ ! -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
1012
+            echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/invite.desktop
1013
+            echo 'Version=1.0' >> /home/$MY_USERNAME/Desktop/invite.desktop
1014
+            echo 'Name=Create Invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
1015
+            echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/invite.desktop
1016
+            echo 'Comment=Create an invite for Patchwork or Ferment' >> /home/$MY_USERNAME/Desktop/invite.desktop
1017
+            echo 'Exec=mate-terminal -e freedombone-mesh-invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
1018
+            echo 'Icon=/usr/share/freedombone/avatars/invite.png' >> /home/$MY_USERNAME/Desktop/invite.desktop
1019
+            echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/invite.desktop
1020
+            echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/invite.desktop
1021
+        fi
1022
+    else
1023
+        if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
1024
+            rm /home/$MY_USERNAME/Desktop/invite.desktop
1025
+        fi
1026
+    fi
1006 1027
 else
1007 1028
     if [ -f /tmp/Users.txt ]; then
1008 1029
         rm /tmp/Users.txt
@@ -1031,6 +1052,13 @@ else
1031 1052
         #fi
1032 1053
         pkill qtox
1033 1054
     fi
1055
+
1056
+    # If there is no ethernet then remove the invite icon
1057
+    if [[ "$ethernet_connected" == "0" ]]; then
1058
+        if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
1059
+            rm /home/$MY_USERNAME/Desktop/invite.desktop
1060
+        fi
1061
+    fi
1034 1062
 fi
1035 1063
 EOF
1036 1064
     chroot "$rootdir" /bin/chown $MY_USERNAME:$MY_USERNAME /usr/bin/list-tox-users

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

@@ -311,16 +311,6 @@ function show_desktop_icons {
311 311
     #echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/audio.desktop
312 312
     #echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/audio.desktop
313 313
 
314
-    #echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/invite.desktop
315
-    #echo 'Version=1.0' >> /home/$MY_USERNAME/Desktop/invite.desktop
316
-    #echo 'Name=Create Invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
317
-    #echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/invite.desktop
318
-    #echo 'Comment=Create an invite for Patchwork or Ferment' >> /home/$MY_USERNAME/Desktop/invite.desktop
319
-    #echo 'Exec=mate-terminal -e freedombone-mesh-invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
320
-    #echo 'Icon=/usr/share/freedombone/avatars/invite.png' >> /home/$MY_USERNAME/Desktop/invite.desktop
321
-    #echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/invite.desktop
322
-    #echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/invite.desktop
323
-
324 314
     # set permissions
325 315
     chmod +x /home/$MY_USERNAME/Desktop/*.desktop
326 316
     chown ${MY_USERNAME}:${MY_USERNAME} /home/$MY_USERNAME/Desktop/*

+ 7
- 2
src/freedombone-mesh-batman 查看文件

@@ -407,8 +407,13 @@ function start {
407 407
     systemctl restart avahi-daemon
408 408
 
409 409
     if [ -f /etc/scuttlebot/.ssb/config ]; then
410
-        sed -i "s|\"host\": .*|\"host\": \"$(get_ipv4_wlan)\",|g" /etc/scuttlebot/.ssb/config
411
-        systemctl restart scuttlebot
410
+        ethernet_connected=$(cat /sys/class/net/eth0/carrier)
411
+        if [[ "$ethernet_connected" != "0" ]]; then
412
+            sed -i "s|\"host\": .*|\"host\": \"$(get_ipv4_wlan)\",|g" /etc/scuttlebot/.ssb/config
413
+            systemctl restart scuttlebot
414
+        else
415
+            systemctl stop scuttlebot
416
+        fi
412 417
     fi
413 418
 
414 419
     verify