Only enable scuttlebot on mesh gateways

This commit is contained in:
Bob Mottram 2017-10-06 10:47:35 +01:00
parent ecd0706eac
commit 5865f2633d
3 changed files with 35 additions and 12 deletions

View File

@ -894,6 +894,7 @@ function configure_user_interface {
# Produce a text file on the desktop listing users on the mesh # Produce a text file on the desktop listing users on the mesh
cat <<EOF > $rootdir/usr/bin/list-tox-users cat <<EOF > $rootdir/usr/bin/list-tox-users
#!/bin/bash #!/bin/bash
ethernet_connected=$(cat /sys/class/net/eth0/carrier)
users_list=\$(lstox | awk -F ' ' '{\$1=""; print \$0}' | sed -e 's/^[[:space:]]*//' | sort -d | uniq) users_list=\$(lstox | awk -F ' ' '{\$1=""; print \$0}' | sed -e 's/^[[:space:]]*//' | sort -d | uniq)
if [ ! \$users_list ]; then if [ ! \$users_list ]; then
no_of_users=0 no_of_users=0
@ -1003,6 +1004,26 @@ if [ \$no_of_users -gt 0 ]; then
chmod +x /home/$MY_USERNAME/Desktop/tox.desktop chmod +x /home/$MY_USERNAME/Desktop/tox.desktop
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/tox.desktop chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/tox.desktop
fi fi
# If ethernet is connected then add the invite icon to help enable
# SSB nat traversal
if [[ "$ethernet_connected" != "0" ]]; then
if [ ! -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/invite.desktop
echo 'Version=1.0' >> /home/$MY_USERNAME/Desktop/invite.desktop
echo 'Name=Create Invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/invite.desktop
echo 'Comment=Create an invite for Patchwork or Ferment' >> /home/$MY_USERNAME/Desktop/invite.desktop
echo 'Exec=mate-terminal -e freedombone-mesh-invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
echo 'Icon=/usr/share/freedombone/avatars/invite.png' >> /home/$MY_USERNAME/Desktop/invite.desktop
echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/invite.desktop
echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/invite.desktop
fi
else
if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
rm /home/$MY_USERNAME/Desktop/invite.desktop
fi
fi
else else
if [ -f /tmp/Users.txt ]; then if [ -f /tmp/Users.txt ]; then
rm /tmp/Users.txt rm /tmp/Users.txt
@ -1031,6 +1052,13 @@ else
#fi #fi
pkill qtox pkill qtox
fi fi
# If there is no ethernet then remove the invite icon
if [[ "$ethernet_connected" == "0" ]]; then
if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
rm /home/$MY_USERNAME/Desktop/invite.desktop
fi
fi
fi fi
EOF EOF
chroot "$rootdir" /bin/chown $MY_USERNAME:$MY_USERNAME /usr/bin/list-tox-users chroot "$rootdir" /bin/chown $MY_USERNAME:$MY_USERNAME /usr/bin/list-tox-users

View File

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

View File

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