From c98cecc97f136b28478ed22e9c404dd3d7d38134 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 8 Aug 2015 15:36:27 +0100 Subject: [PATCH] Fix babel script --- src/freedombone | 49 +++++++++++++++++++++++++++++++++++------- src/freedombone-client | 3 ++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/freedombone b/src/freedombone index 5cda15be..e4aabe3d 100755 --- a/src/freedombone +++ b/src/freedombone @@ -1672,18 +1672,49 @@ function mesh_babel { babel_script=/var/lib/babel - echo '#!/bin/sh' > $babel_script - echo 'IFACE=wlan0' >> $babel_script - echo 'IFACE_EXISTS=$(grep "$IFACE" /proc/net/dev)' >> $babel_script + echo '#!/bin/bash' > $babel_script echo '' >> $babel_script - echo 'if [[ ! $IFACE_EXISTS || $1 == "stop" ]]; then' >> $babel_script - echo ' echo "Interface $IFACE was not found"' >> $babel_script + echo 'if [[ $1 == "ls" || $1 == "list" ]]; then' >> $babel_script + echo ' avahi-browse --all' >> $babel_script + echo ' exit 0' >> $babel_script + echo 'fi' >> $babel_script + echo '' >> $babel_script + echo 'if [[ $1 == "start" ]]; then' >> $babel_script + echo ' sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script + echo ' sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script + echo ' if [ -f /bin/systemctl ]; then' >> $babel_script + echo ' systemctl restart avahi-daemon' >> $babel_script + echo ' else' >> $babel_script + echo ' service avahi-daemon restart' >> $babel_script + echo ' fi' >> $babel_script + echo 'fi' >> $babel_script + echo '' >> $babel_script + echo 'IFACE=wlan0' >> $babel_script + echo 'if grep -q "wlan1" /proc/net/dev; then' >> $babel_script + echo ' IFACE=wlan1' >> $babel_script + echo 'fi' >> $babel_script + echo '' >> $babel_script + echo 'if [[ ! grep -q "$IFACE" /proc/net/dev || $1 == "stop" ]]; then' >> $babel_script + echo ' if ! grep -q "$IFACE" /proc/net/dev; then' >> $babel_script + echo ' echo "Interface $IFACE was not found"' >> $babel_script + echo ' else' >> $babel_script + echo ' echo "Stopping"' >> $babel_script + echo ' fi' >> $babel_script echo ' ifconfig $IFACE down' >> $babel_script - echo ' systemctl restart network-manager' >> $babel_script + echo ' pkill babeld' >> $babel_script + echo ' if [ -f /bin/systemctl ]; then' >> $babel_script + echo ' systemctl restart network-manager' >> $babel_script + echo ' else' >> $babel_script + echo ' service network-manager restart' >> $babel_script + echo ' fi' >> $babel_script echo ' exit 1' >> $babel_script echo 'fi' >> $babel_script echo '' >> $babel_script - echo 'systemctl stop network-manager' >> $babel_script + echo 'if [ -f /bin/systemctl ]; then' >> $babel_script + echo ' systemctl stop network-manager' >> $babel_script + echo 'else' >> $babel_script + echo ' service network-manager stop' >> $babel_script + echo 'fi' >> $babel_script echo 'ifconfig $IFACE down' >> $babel_script echo -n 'iwconfig $IFACE mode ad-hoc channel ' >> $babel_script echo "$WIFI_CHANNEL essid \"$ESSID\"" >> $babel_script @@ -1693,7 +1724,8 @@ function mesh_babel { echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script - echo "$BABEL_PORT -d 5 wlan0" >> $babel_script + echo -n "$BABEL_PORT -d 5 " >> $babel_script + echo '$IFACE' >> $babel_script echo 'exit 0' >> $babel_script chmod +x $babel_script @@ -1781,6 +1813,7 @@ function mesh_batman_bridge { echo ' modprobe batman-adv' >> $batman_script echo ' batctl if add $IFACE' >> $batman_script echo ' ifconfig $IFACE up' >> $batman_script + echo ' avahi-autoipd $IFACE' >> $batman_script echo ' ifconfig bat0 up promisc' >> $batman_script echo '' >> $batman_script echo ' #Use persistent HWAddr' >> $batman_script diff --git a/src/freedombone-client b/src/freedombone-client index 98cdba5a..cf192019 100755 --- a/src/freedombone-client +++ b/src/freedombone-client @@ -147,7 +147,8 @@ function mesh_babel { echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script - echo "$BABEL_PORT -d 5 wlan0" >> $babel_script + echo -n "$BABEL_PORT -d 5 " >> $babel_script + echo '$IFACE' >> $babel_script echo 'exit 0' >> $babel_script chmod +x $babel_script sudo mv $babel_script /usr/bin/babel